Browser Caching for WordPress Best Practices

What is a browser cache for WordPress?

Typically, on each page load, the browser reads each file required and loads these resources. With browser caching for WordPress enabled, if you visit one page and the same static resources are required on the next page you visit (for example the site’s logo), then you won’t have to load it again – it will be stored in your cache, and the browser can access this locally, which is significantly faster.

WordPress is a dynamic CMS. This means that each time a user visits your website, WordPress fetches information from the database and then runs several other steps before the web page is sent to the user’s browser. This makes your website load slower when a lot of users are visiting it at the same time.

Caching allows your WordPress site to skip a lot of steps. Instead of going through the whole page creation process every time, your caching plugin makes a copy of the page after the first load, and then serves that cached version to every subsequent user – not just you.

Should I use browser caching for WordPress?

Browser caching for WordPress is usually recommended. The only reasons you may not want to enable caching are:

  • The site is still under development
  • Updates are being made consistently to the site (existing, not new pages)
  • Your combined/minified files don’t have a version tag
  • Your site doesn’t have an easy way to clear the cache

If updates are consistently being made to the site, it is important to consider the lifetime of your cache. For example, if there are constant updates, this will cause issues if your browser cache is set to last for days or weeks – but might be perfectly fine to ‘set and forget’ if it resets every day. This timing (usually in seconds) can typically be set within your caching plugin of choice.

If you utilise combined/minified files and these shorten the file url, sometimes it can also strip the version query at the end of the URL. This can cause issues if the cached copy becomes out of date but is still being served to users. Either manually clearing the cache will be required, or enabling versions.

How to enable browser caching for WordPress

Luckily, it is very easy to enable browser caching for WordPress – it can be achieved with an caching plugin.

Typically the plugins that enable browser caching for WordPress also have many other features that we have talked about on this site, included minification, combination, lazy loading, and more. There are many good options out there, however some have more or specific features that you may wish to use. As all sites are different and all plugins behave uniquely, we recommend testing a range on your site. This should allow for ensuring no issues occur, and having the right feature set.

Recommended Browser Caching WordPress Plugins

If you are using OpenLiteSpeed, then you will use LS Cache.

If you are on any other web server, my preference is for AutoOptimize, and it’s additional connector plugin, Async Javascript.

All of these options are free. If you are looking at paid options, WP Rocket comes highly recommended also.

Browser Caching for WordPress with a CDN

In addition to plugins, it is important to know what a CDN does and how this affects browser caching.

Popular CDN CloudFlare allows for browser caching, even on their free tier – and that’s without adding a WordPress plugin. You can also choose the time the cache remains alive, from hours to over a month.

The CDN works to serve static files for your site over an optimized connection – it doesn’t matter to the CDN if the files are the original, or if they have already been minified and combined via a plugin – it will simply serve those files instead.

Need help adding browser caching for WordPress?

This is part of our optimization service. We can help you optimize your site above and beyond browser caching, just let us know what you are trying to achieve, and we will let you know how we can help.