75% OFF ALL NEW PLANS TO HELP MORE BUSINESSES MOVE ONLINE

Enabling server-side caching for WordPress

Server-side caching may help reduce page load times by a significant margin if configured properly. You can learn more about the server-side caching service in the General information about server-side caching article.

To take advantage of server-side caching on a WordPress website, you need to:

  1. Configure WordPress to cache content.
  2. Choose how to clear the cache.
  3. Enable server-side caching.

1. Configure WordPress to cache content

You should configure your WordPress installation to send the correct caching headers.

If you have installed your WordPress instance using the WordPress section of the hosting Control Panel, content caching should be already enabled for your WordPress installation. Otherwise, you can enable it by following the instructions from our Optimizing WordPress article.

By optimizing your WordPress installation through the hosting Control Panel, the following line of code will be added to your .htaccess file, which will guarantee that a separate cache entry gets created for every different User Agent (browser):

Header append Vary User-Agent env=!dont-vary

If you don't want to have a separate cache entry for every User Agent, you should comment or remove that line from the main .htaccess file of your WordPress installation.

Alternatively, you can install a plugin that allows you to set caching headers. The Cache-Control plugin has proven to work correctly on our servers.

Note: We advise that you do not combine multiple tools/methods that set HTTP Cache-Control headers as this may lead to unexpected results.

2. Choose how to clear the cache

You can configure WordPress to clear the server-side cache automatically whenever content is changed. All you need to do is download and activate the Server-Side Cache Autopurge plugin for your WordPress installation. The plugin works correctly out of the box, so no additional configuration is required. This plugin also allows you to purge the cache on demand via the “Purge Server-Side Cache” button at the top left side of the WordPress Dashboard, as well as via WP-CLI with the following command:

wp surecache purge

If you do not wish to install or use the Server-Side Cache Autopurge plugin, or you do not update content regularly, you can purge the server-side cache manually by using any of the methods listed in our Purging the server-side cache article.

3. Enable server-side caching

Once you have prepared WordPress for server-side caching, you can enable the server-side caching service by navigating to the hosting Control Panel's Server-side Caching section and clicking on the Enable button next to the domain/subdomain where your WordPress is installed.