Hey guys, Our woocommerce store is using checkout-x and we have issues with discount coupons due to API caching.How do I reconfigure that ?
Here is the response from their support team.
So, what you need to do is to reconfigure Cloudflare . Currently, some API responses are being cached, and caching API requests is not a good practice in general because of the risk for stale responses.
Hey guys, Our woocommerce store is using checkout-x and we have issues with discount coupons due to API caching.How do I reconfigure that ?
Here is the response from their support team.
So, what you need to do is to reconfigure Cloudflare . Currently, some API responses are being cached, and caching API requests is not a good practice in general because of the risk for stale responses.
It turned up that we synced the coupons when they were created/updated as expected, but they were deleted afterward for no reason. This happened because:
We sync the discounts every time they are used at the checkout. We update them if they are stale and delete them if they are not found in WooCommerce.
We use a more specific request when getting the data from WC vs when we sync - adding the code=CODE parameter in the URL. Turns out your store is using Cloudflare and Cloudflare returns us a cached version of this URL’s response (errored response - “invalid_grant”), the parsing of the response errors out, we rescue the error and return nil which leads to deleting the discount.
So, what you need to do is to reconfigure Cloudflare . Currently, some API responses are being cached, and caching API requests is not a good practice in general because of the risk for stale responses. Cloudflare has a guide on how to use them for APIs. Please, follow the recommendations in it https://support.cloudflare.com/hc/en-us/articles/200504045-Using-Cloudflare-with-your-API.
For a quick temporary fix, you can at least purge the Cloudflare cache. Here are some specific technical info about the caching problem:
Request like this one are not currently cached https://mydomain.com/wp-json/wc/v3/coupons?consumer_key=*******consumer_secret=*********
While requests to the same URL with other parameters are currently cached https://mydomain.com/wp-json/wc/v3/coupons?code=whatever&consumer_key=*******&consumer_secret=****
here are the URLs they mentioned. Not sure what rules should we configure as per their comments. Thanks in advance.
Here are some specific technical info about the caching problem:
Request like this one are not currently cached https://twofussyblokes.com/wp-json/wc/v3/coupons?consumer_key=*******consumer_secret=*********
While requests to the same URL with other parameters are currently cached https://twofussyblokes.com/wp-json/wc/v3/coupons?code=whatever&consumer_key=*******&consumer_secret=****