How to set up Wordpress to use the HTTP cache of


Configure Wordpress to send proper cache-control headers, so the HTTP cache can be used.



By default, Wordpress doesn’t set proper headers to allow the build-in HTTP cache to work efficiently.

You can test if your site is cached based on the x-platform-cache response header which will probably be a MISS with the default Wordpress installation.


1. Install and enable the cache-control plugin

The main configuration that the HTTP cache needs to work properly, is Cache-Control header. Since Wordpress does not include an option to set those headers in their core, you need to use a 3rd party plugin. The example used here is cache-control.

If you have set up your project to use a composer-based installation of plugins (see here on how to do this), you can use composer require wpackagist-plugin/cache-control locally to update your composer files.

After that commit and push them so the plugin gets deployed to your project. In the Admin-Dashboard go to Plugins, find Cache-Control and click Activate.

2. Verify and adjust the header values

In the plugin settings, you can adjust the time different sites is being cached (e.g home page, post sites, etc). You can adjust that as necessary, following good practises.


3. Settings for static assets

For static assets, the Wordpress template includes a default Cache-Control of 600 in your file. To adjust that (if needed), you find the expires setting in the location block.

4. Verify your site is being cached

To check if the response is cached, you can use curl -I to retrieve the headers. While the first response might be a MISS (because the page has not been cached yet), as soon as you send the same request again, it should return HIT.

curl -I
HTTP/2 200
cache-control: max-age=300
x-platform-cache: HIT


With this setup, your Wordpress site can leverage the HTTP Cache and you have control over the caching behaviour for different parts of your Wordpress site.

1 Like


I’ve tried this but still get cache miss, I think there maybe something wrong with the Wordpress theme but not sure where to look to try and find what’s stopping it from caching.

Thanks Dan

After installing that plugin I’m getting this message on all pages.

Warning: Cannot modify header information - headers already sent by (output started at /app/web/wp/wp-admin/includes/class-wp-filesystem-ftpext.php:560) in /app/web/app/plugins/cache-control/cache-control.php on line 359

This will occur if another plugin/theme has caused an error or has sent output to the browser before the cache-control plugin can send the caching-related headers. In your warning message, it references class-wp-filesystem-ftpext.php which indicates something in your set up was attempting to write to the file system. Given the application container on is read-only it would be unable to and fail. In order to determine the root cause, you may want to install the Query Monitor on a local copy or in a development instance.

I’ve installed a WP instance. Users can’t login, because of a 302 error on login page. It seems to come from this cache issue (x-platform-cache = MISS)
Since i can’t connect, i can’t tweak this plugin. How can i proceed to activate cache on my website ?


I’ll need some information to help debug your issue. In your .platform/routes.yaml file (docs), what do you have set for <route>:cache:cookies ? Docs.

For WordPress, it should be something similar to:

    type: upstream
    upstream: "app:http"
    # supports HTTP caching at the server level. Caching is enabled by default, but is only applied to
    # GET and HEAD requests.
    # More information:
        # All possible cache configuration options:
        enabled: true
        # Base the cache on the session cookies. Ignore all other cookies.
            - '/^wordpress_'
            - 'wordpress_test_cookie'
            - '/^wp-'

I should have asked earlier: is this a single-site-instance WordPress, or a multisite?

Also, how is your wp-config.php file constructed? Specifically, are you defining WP_HOME and/or WP_URL and if so, what are you using for those values?

I’m struggling to find a way to access DB with a client like Workbench.

For that, you’ll need to set up an ssh tunnel.

Alternatively, you can use the cli tool to get a MariaDB shell on the container using the platform sql command OR if you ssh into your app container, you can use the wp db cli command to get to the same place.