Enabling server-side caching for Drupal 8/9/10
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/10 website, you need to:
- Configure Drupal 8/9/10 to cache content
- Choose how to clear the cache
- Enable server-side caching
1. Configure Drupal 8/9/10 to cache content
By default, Drupal 8/9/10 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.
To have Drupal 8/9/10 clear the cache automatically when you make any changes to your website content, please follow these steps:
- Extend your Drupal 8/9/10 installation by adding the Purge and Generic HTTP Purger modules.
- 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
- Navigate to the Administration -> Configuration -> Development -> Performance section, and select the Purge tab that is now available.
- Click on the add purger button from the Cache Invalidation menu.
- Select the HTTP Purger radio button from the pop-up window that appeared.
- Click on the Add button.
- 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.
- Enter a name that describes the purger (e.g. Cache purger) in the Name field.
- 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/10 is installed)
• Port: 80 (default value)
• Path: / (default value)
• Request Method: BAN (default value)
• Scheme: http (default value)
Note: If your Drupal 8/9/10 installation is configured to always work over HTTPS, you should change the Port setting to 443 and the Scheme to https.
- 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/10 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.
Once you have prepared Drupal 8/9/10 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.