My shopping cart is being cached by w3 total cache. This is the expected default behaviour. The thing is I can’t find an easy solution for this.
I am showing my shopping cart on almost every page, so using rejected cookies or something similar is not an option. Is it possible to tell w3 total cache not to cache a single php file like cart_widget.php? Or some other workaround?
I know there is the possibility to load the cart via ajax as the plugin does not cache GET requests with parameters (by default). Still, I would like to avoid that extra request.
EDIT: Also, w3 total cache is not regenerating the page when I edit the product, is there an easy way to tell w3 total cache to empty the cache for a single page?
W3 Total Cache is a very advanced plugin that has built in ways to handle almost any situation.
To exclude a page from being cached use one of the following commands below:
To make W3 Total empty the cache on your product edit you can hook the following function in when the product is saved:
To implement fragment caching wrap the functions or lines of code that you don’t want to cache in an mfunc:
W3, like all other plugins of this kind, caches page output in static file. Basically you can’t have part of static file being non-static.
I am no expert in this field, but I would suggest to look into cookies after all. For example you can try to leave cache for pages with empty cart, but make filled cart set some cookie and skip caching on that.