How do I know my webpage is being cached (or why it isn’t)?

Make sure you are getting the page from the webserver (rather than from your browser cache) by emptying your browser cache and reloading the page. Do this whilst logged out (because the default setting is not to serve cached pages for logged-in users, since logged-in users usually want live content). Then, use the “View Source” function in your web browser to view the page source. Scroll down to the bottom, and you should see a line added by the cache:

HTML source showing that the page was served from the cache

However, note that if you are using a further service that minifies HTML (e.g. Cloudflare), then this line may have been removed. Another method is to inspect the contents of the directory wpo-cache inside your wp-content directory.

If your page is not being served from the cache, and you want to find out why not, then firstly – are you sure it is not being so served? As just mentioned, minification will remove HTML comments, like the line above. If you are sure, then you should edit your wp-config.php file, and change the WP_DEBUG setting to true, like so:

define('WP_DEBUG', true);

Then, reload the page, and view the HTML source. The reason will be given at the bottom – if it is not being removed by minification. If you need to first turn off minification, then do so.

HTML comment showing why the page was not served from the cache

Posted in: Cache