HTTP Cache Control
This module provides fine-grained control over Drupal's HTTP cache control headers, allowing you to configure cache lifetimes for various response types including errors and redirects, and to set advanced cache behaviors like stale-if-error and stale-while-revalidate. It also allows customization of the `Vary` header to cache content based on request headers.
HTTP Cache Control module helps fine grain control of Drupal's Cache Control headers.
Cache Features
- Support for shared cache max age (s-maxage)
- Support for Surrogate-Control (Fastly CDN) (2.x only)
- Ability to set cache lifetime of 404 pages
- Ability to set cache lifetime of 302 Redirects
- Ability to set cache lifetime of 500 level error pages (when in control by Drupal)
Revalidation Features
- Support for stale-if-error allowing cache proxies to server stale cache in place of an error from Drupal for a fixed period of time.
- Support for stale-while-revalidate allowing cache proxies to serve stale cache to other users while a cached item is being revalidated.
Variation
This module allows you to add arbitrary headers to the Vary response header to variate
upstream cache by the type of request headers sent.
Installation/Configuration
Simply download and install this module as per normal. Then go to the performance configuration page (admin > configuration > performance) and set the cache lifetimes accordingly.
Caution
This is an advanced module, care should be taken when fine tuning cache control headers. Please consider reading the HTTP spec on Cache Control headers: https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
Depends on
Dependencies of the latest stable release
No dependencies recorded for this project.
Required by
Tracked projects that depend on this one
No tracked projects depend on this one yet.
Activity
Release Timeline
Releases
| Version | Type | Core | Notes | Release date | |
|---|---|---|---|---|---|
| 8.x-2.9 | Stable | 9–11 | Fix the 5xx cache maximum age setting not being removed. | Feb 6, 2026 | |
| 8.x-2.8 | Stable | 9–11 | Fix targeted cache control form not being properly validated. | Jan 5, 2026 | |
| 8.x-2.7 | Stable | 9–11 | Add support for targeted cache-control headers & remove the 5xx cache maximum age setting. | Dec 30, 2025 | |
| 8.x-2.6 | Stable | 9–11 | Fix 'TypeError: http_cache_control_module_implements_alter(): Argument #2 ($hook) must be of type string, int given' | Feb 28, 2025 | |
| 8.x-2.5 | Stable | 9–11 | Stop assigning 404/302/301 TTL's to the max-age header | Dec 27, 2024 | |
| 8.x-2.4 | Stable | 9–11 | Allow choosing more fine-grained max-ages, improve documentation & fix some settings not working. | Dec 3, 2024 |