A client has an Apache mod_cache version that is ignoring Cache-control and only looking at Expires, so I've been looking at using this module to override the default Dries' birthday value. I realise this used to be a bad idea, but we're going to go with the info in https://stackoverflow.com/questions/2073392/is-http-1-0-still-in-use and assume to start with that HTTP 1.0 is close to dead, if not there yet.

To test the setting of the Expires header, I performed a fresh install of Drupal and enabled this module, then set a one minute max-age at /admin/config/development/performance. As an anonymous user, however, I continued to get the 1978 Expires value. I found that the FinishResponseSubscriber sets the 60 second max-age value but doesn't modify the cacheabilityMetadata, leading to the observed issue.

As a result, I'm wondering why the module gets $max_age from the CacheableMetadata rather than the header that's actually going to be sent

$max_age = $response->getCacheableMetadata()->getCacheMaxAge();

instead of

$max_age = $response->headers->getCacheControlDirective('max-age');

Am I right in thinking it's because you're focussed on the bubbled max-age tags and not the Performance page setting?

In any case, I'll attach a patch that changes the above line, if only so that I can reference it in my composer.json (but hopefully to aid understanding / development of a way forward too!)

Comments

NigelCunningham created an issue. See original summary.

nigelcunningham’s picture

StatusFileSize
new639 bytes
dpi’s picture

Status: Active » Closed (cannot reproduce)

By default the CC value does come from system.performance:cache.page.max_age, the value found on performance form.

The max age comes from the bubbled response, whether its a render array (via \Drupal\Core\Render\HtmlResponse or a plain \Drupal\Core\Cache\CacheableResponse (via app/core/lib/Drupal/Core/Cache/CacheableResponse.php)

I think we're good here.