Install
Works with Drupal: ^10.1 || ^11 || ^12Using Composer to manage Drupal site dependencies
Alternative installation files
Release notes
A bug fix release for a regression in 4.2.0, with one behaviour change for redirects. No API changes, no change to the supported core versions, no change to the shipped VCL.
If you are on 4.2.0, please upgrade. On a site that never changed the core "Browser and proxy cache maximum age" setting, 4.2.0 does not cache anything in Varnish.
Varnish cached nothing with the default core setting
Core ships with "Browser and proxy cache maximum age" set to no caching, and in that state it marks every response must-revalidate, no-cache, private. 4.2.0 started to respect a Cache-Control header set by a controller #3586257: CacheableResponseSubscriber overrides custom Cache-Control headers set by controllers, and mistook that core default for one. The header went to Varnish untouched, and Varnish refuses to store a private response. #3636699: Default Drupal max page cache setting disables Varnish caching
- Anonymous pages were not cached unless the core lifetime had been raised on the Performance page. The lifetime configured in the module was ignored.
- "Enable varnish for authenticated users" had no effect at any core lifetime, because core marks every response to a logged in user the same way.
- A Cache-Control header attached to a render array was replaced by the module default. Headers set through
#attached['http_header'], including ones attached by a placeholder or a lazy builder, are applied by core after the module looks at the response. They are now read from the final response, so a page that asks forno-storeor its owns-maxagegets it.
The module now decides from the header the controller set, before core adjusts it. A response without one gets the module lifetime again, whatever the core setting is.
Updating your VCL
Nothing to do. varnish/default.vcl is the same as in 4.2.0.
Testing
The suite is green on Drupal 10, 11 and 12. This regression got through because every test and every test site ran with a raised core lifetime, so the default was never exercised. The header tests now run at both the core default and a raised lifetime, and a new test installs the module on an untouched site and checks what Varnish would receive. The fix was also verified against a live Varnish 9.0: an anonymous page goes MISS then HIT at both lifetimes, two users with the same roles share the page while each sees their own ESI block, and a redirect is never held.
Reported by Eelke Blok. Fixed by Eelke Blok and Andrey Rachinskiy.