Provide the ability 'un-cache' time critical data
AnsweredThe use of Cloudflare and caching has many advantages, how there are a couple of example where caching is causing problems.
Example 1:
- Product stock qty is updated in AC via the API. (i.e. the product goes from 0 stock on hand and 'back order' status, to 5 stock on hand and 'in stock' status)
- This update immediately triggers a 'item back in stock notification email'
- The customer clicks on that email link, only to find the item still shows 'sold out' on the front end.
Due to caching, at some point, the front end will eventually correctly update to 'in stock' ...but the timing of that update is unknown... it needs to be instant.
Example 2:
- Advanced pricing is updated in AC via the API.
- Same as example 1... the pricing eventually updates... but 'when' is a mystery.
The current work-around is a manual re-save of the relevant product in admin and/or using the cache refresh option via live design.
This is obviously not practical for 100's of API updates each day.
In order to rectify this, we either:
1/ The ability to trigger an immediate cache refresh via the API call
or
2/ Have the ability to exclude certain data fields from caching/cloudflare (which would have minimal impact of performance). The fields we consider time-critical are:
'advanced pricing'
'product status'
'inventory qty'
Cheers
(AC dev, this relates to support ticket #219794 - we were advised to post this as a feature request)
-
Only static files are cached at Cloudflare, so the dynamic product page would only have small elements that are cached and shouldn't be caching things that are dynamically rendered (aka stock status and pricing). We do however cache the 'data' of a product on the webserver locally just to avoid repeated lookups within a very small window. This may be what you're seeing stick around. Saving a product, system updates to that product or clearing cache all wipe that information out. However, the API likely does not, since that is an entirely separate application that is separated in many ways from the application that serves your store. So the api has troubles talking to the web app to clear that cache.
With all of that fun context, lol, I agree, a feature to auto-clear when the api changes the product would be ideal. Or at least a way to clear the cache via your api calls when you're 'done'. We do have a way to do the latter. This post should focus on the idea of doing it automagically.
As for clearing it after you're done changing products/inventory programatically, you can use option 2 here: https://support.americommerce.com/hc/en-us/articles/203052310-Changes-not-Showing-Clear-Cache-Purge-CDN
Just make a web request via your code to that url (not after every save, but periodically when you've done a large batch ideally). If you have multiple stores, you'll have to do it for each store. This will clear the application cache. I believe this does not clear the Cloudflare CDN cache (not sure on that).
Hope this helps!
0
Please sign in to leave a comment.
Comments
1 comment