Enabling server-side caching for Drupal 8/9

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 available on our servers in the General information about server-side caching article.

To take advantage of server-side caching on a Drupal 8/9 website, you need to:

  1. Configure Drupal 8/9 to cache content
  2. Choose how to clear the cache
  3. Enable server-side caching

1. Configure Drupal 8/9 to cache content

By default, Drupal 8/9 allows you to specify for how long the cache should be stored via the max-age and Cache-Control headers. You can select your preferred caching period via the Caching menu from the Administration -> Configuration -> Development -> Performance section. We would recommend that you set the caching period to 1 year for best results after enabling the server-side caching.

2. Choose how to clear the cache

To have Drupal 8/9 clear the cache automatically when you make any changes to your website content, please follow these steps:

  1. Extend your Drupal 8/9 installation by adding the Purge and Generic HTTP Purger modules.

  2. Install the following components:

    Purge module - Purge, Purge Tokens, and Purge UI components
    Purge - Processors module - Late runtime processor component
    Purge - Queuers module - Core tags queuer component
    Purge - reverse proxies & CDNs module - Generic HTTP Purger and Generic HTTP Tags Header components

  3. Navigate to the Administration -> Configuration -> Development -> Performance section, and select the Purge tab that is now available.

  4. Click on the add purger button from the Cache Invalidation menu.

  5. Select the HTTP Purger radio button from the pop-up window that appeared.

  6. Click on the Add button.

  7. A new purger will appear above the add purger button. Open its menu by clicking on the downward pointing arrow on the button, select the Configure option, and a new window will pop up.

  8. Enter a name that describes the purger (e.g. Cache purger) in the Name field.

  9. In the Request tab, enter the following settings:

    Hostname: your_domain.com (Make sure you replace your_domain.com with the actual domain/subdomain where Drupal 8/9 is installed)
    Port: 80 (default value)
    Path: / (default value)
    Request Method: BAN (default value)
    Scheme: http (default value)

    Note: If your Drupal 8/9 installation is configured to always work over HTTPS, you should change the Port setting to 443 and the Scheme to https.

  10. In the Headers tab, enter the following settings:

    Header: Purge-Cache-Tags
    Value: [invalidation:expression]

Alternatively, you can purge the server-side cache for your domain/subdomain manually by using any of the methods provided in our Purging the server-side cache article.

Note: If you do not configure Drupal 8/9 to clear the cache automatically when content is changed, the Clear all caches button from the Administration -> Configuration -> Development -> Performance section will clear its local cache, but the server-side cache will not be cleared.

3. Enable server-side caching

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