Traffic spikes tend to hit one or two pages on your site, so to profit from traffic spikes you need to ensure everything is cachable and that everything is actually cached.
Pages are only cachable if they do not have unique content per user. Unique content per user includes things like:
- Wishlist widget – if it generates the content through PHP (server-side) rather than using JavaScript/Ajax, then this is producing unique content per user and prevents page-caching
- Basket widget – if your basket widget generates a number using PHP rather than Ajax then your pages are not cachable
- Recently viewed products widget – if your widget generates the view of recently viewed products through PHP then the pages cannot be cached as other users would then see this users recently viewed products instead of their own
Cache-busting Plugin blacklist
This list will grow as I gather more plugins to add to the blacklist. If you are the author of one of these plugins, get in touch and I can explain how to make your plugin behave nicely with page-caching plugins.
- Yith Wishlist – if a page is cached, the next user will see the last users wishlist
- WooCommerce recently viewed products widget – if a page is cached, the next user sees the previous uses recently viewed products
- Simple Ajax Chat – it spits out user-specific Javascript inside a PHP page. This means if you cache the page, the 2nd user will be able to talk to admin as if they are the first user…
If you know of any more, or have any you’d like to investigate please comment below.
Is it possible to keep cloudflare full html cache or server level cache when someone add a product on his cart?
Usually it is when cache is gone.
I use generatepress theme and couldn’t find a way.
Yes, but there’s no plugin I’m aware of yet that does this. Some of my clients have custom-built ajax code to make the basket completely ajax driven so the entire page can still be cached. I’ve had a plan for a while to build a plugin to fix this entire cart issue for high-traffic-spike sites, but I’m still busy upgrading all the plugins I have already!
I would be first customer for that plugin 🙂
Why don’t you contact the authors and let them know? I’m a little confused as to what you are pointing out in the article. I do use Yith Wishlist and the built-in recently viewed products widget.
Which caching plugins cause this? What did you use in your tests?
I can simply disable caching on the wishlist page, but the recently viewed has to be dynamic, are you saying caching plugins usually cause it not to be?
What I was trying to point out is that there are some plugins which create content on your site unique to each USER or VISITOR. For example – a wishlist basket, that’s unique per user. Recently viewed products – unique per user. You can probably think of others.
These plugins, depending on how they are coded, prevent the use of page-caching because if you cache a page for User A you cannot present it to User B.
Well written plugins would have the exact same code on the page for User A and User B but would retain a cookie on User A’s computer or User B’s computer and then JavaScript would be used to contact the server and fetch the unique contents for this user.
I did try contacting Yith through their support pages – they may have fixed it by now, I have not checked recently, but back when I checked, the advice from Yith was to ‘disable your page caching’ – hardly a viable approach for a scalable website.