Caching can be a useful tool for speeding up your website, but it can also be frustrating when you can’t clear the cache properly, or things are being cached that shouldn’t.
Recently, I experienced an issue where a page kept caching, even though there was an exception rule which should have prevented it from caching within the caching plugin I was using, WP Rocket.
To resolve this issue, I wrote some PHP no cache code on the template controlling the blog page. The effect was immediate and the caching on the blog page stopped.
Below is the code snippet you can use if you are experiencing a similar issue.
header('Cache-Control: no-cache, no-store, must-revalidate'); header('Pragma: no-cache'); header('Expires: 0');
This code must be inserted within the PHP template for the page on which you want to disable caching.