Thinking Ahead

Page Caching Gotchas in WordPress

wordpress on computer screen

Caching is storing temporary copies of data from one request, so that future requests can access that data faster. In WordPress, many things can be cached such as an entire web page, or the results of a specific database query. In this article we’ll be focusing on page caching and some common mistakes to avoid when you use page caching on your website.

Page Caching

WordPress is a database-driven system, meaning actions like fetching a page require database queries and PHP (code) processing, which are operations that take time. A page cache basically turns WordPress into a static HTML site by eliminating the need for PHP (the code) and MySQL (the database) when a web page is cached — this leads to a decrease in page load time. Page caching generally gives the most significant performance boost in terms of load times and server throughput with a minimal amount of effort compared to other caching types, but it does have limitations.

Pages with Personalized, Dynamic Content Can’t Be Cached

Only static pages can be cached. A static page is rendered identically for every visitor, so it can be reused and served to multiple visitors. If your website only has static pages you will experience significant gains from using a page cache. Page caching becomes tricky when sites have personalized and dynamic content. Often the page cache will need to be disabled or bypassed on certain pages with personalized content. For example, a cart page couldn’t be cached because it displays each visitors’ unique cart items.

This is where individual plugin settings become relevant. Many WordPress caching plugins address this issue of dynamic content in different ways including: 

  1. Not caching page views for logged in users — Your logged in users will miss out on the speed benefits of loading a cached page. Object Caching is another caching type that you may want to consider to benefit logged in users.
  2. Using a user specific cache — Meaning each user has their own cached version of pages. You’ll see less performance gains here because user B cannot receive the page that was previously cached for user A.
  3. Manually blocking pages with dynamic content from being cached at all — It’s difficult to identify all the parts of your site that are using dynamic content.

Even after configuring settings and blacklisting pages with dynamic content, don’t be surprised if some things on your site end up breaking and need some more attention. Each WordPress site has a unique combination of software (themes, plugins, etc.), any of which may have features that are dynamic and unique that you don’t know about. 

Cache invalidation can be difficult due to the dynamic nature of WordPress

Cache invalidation is the process of replacing or removing data in a cache. Let’s say you update a page on your site, the now outdated version of that page stored in the cache needs to be removed from the cache (invalidated). Because WordPress is very dynamic, it’s hard to figure out exactly which pages should be removed from the cache when content is updated. You’ll likely want to purge the entire page cache when content changes to be sure that outdated content is cleared. Almost every caching plugin will have a button or option for clearing the entire cache. 

Using Multiple Page Caching Softwares Won’t Improve Performance

Using multiple page caching solutions will likely slow your website down due to cache incoherency, which is when different versions of your site are stored in each cache. Naturally, cache incoherency makes cache invalidation even harder as well because you’re dealing with multiple caches that contain different data. It is 100% better to avoid this problem altogether by only using one plugin/software to do page caching. 

Page Caching Summary

If you’re looking for a plugin to speed up your website, consider taking advantage of preloading using the Padeo WordPress plugin. This plugin makes your website faster by intelligently preloading content that the user will need in the near future. There’s no configuration and no caveats to worry about it, it just works. Padeo pairs extremely well with caching solutions because it speeds up other steps in the loading process that caching plugins don’t affect.

Exit mobile version