Here’s a quick tips ‘n tricks type of article where I’m gonna share with the world another one of my “obvious tutorials” where I shine a light on something that’s very obvious, so obvious that we end up missing it completely. What I would like to talk about is one of the perils of using caching plugins with WordPress. What I would like to talk about is the importance of flushing the cache once that you’ve made a change to the website, edited template, changed plugin setting, etc.
Wait a minute, what are caching plugins in the first place?
I don’t wanna make this a long read, but this has to be said. A caching plugin is a plugin that takes your WordPress pages and creates static HTML snapshots of them. Normal WordPress install recreates the page using PHP (its HTML formatting) every time a visitor opens it. This puts extra strain on the server. With static HTML snapshots, server displays HTML documents instead, there’s no need for PHP to get involved and slow the server down.
That’s neat, so what’s the problem?
The problem lies in the fact that once you start using caching plugins your website is a bit less dynamic. When a HTML snapshot is created, only changes present on the website at the time that the snapshot was created will be visible when someone visits your website.
Here’s an example, you activate one of the dozens available caching plugins for WordPress and all is well, plugin works, website is faster, you’re over the moon. But, but!
Now you decide that you want to add Adsense to your website. You edit your template, add the Adsense code save everything, refresh the page but nothing shows up. Why isn’t Adsense showing up, everything’s OK with the code. Then you remember that the caching plugin took a HTML snapshot of the website before you added the Adsense code and now the old unedited version of the template is being showed.
How can I fix this problem then?
To avoid having problems like the one described above, you just need to make sure that the entire cache is deleted after you’ve made a change to your website.
WP Fastest Cache, which is the caching plugin that I’m using, has an option where the entire cache is deleted automatically after a post has been published. If for some reason the cache isn’t deleted automatically, open up plugin settings and search for the “Delete Cache” option. With the cache deleted, plugin will be forced to create new HTML screenshots and by doing that all the changes that you’ve made are gonna be detected and kept until the next time that the cache starts causing problems.