Repeatable: Always
Steps to repeat:
1. Create a new controller in a module
2. Return a render array from within the controller just like this
function testControllerCache() {
return [
'#markup' => '<pre>' . date('date('i:s')') . '</pre>',
'#cache' => [
'tags' => ['test_tag_should_appear_on_response_headers'],
'max-age' => 10,
],
];
}
3. Access the page twice from the corresponding route and check headers, the second access should return a
X-Drupal-Cache: HIT
Expected Results:
The page should be invalidated after 5 seconds and regenerated on request
Actual Results:
The page is cached until 'test_tag_should_appear_on_response_headers' is invalidated
Proposed resolution
The Page Cache Module checks for an Expires header, to set expire times, but it should check page's 'max-age'
as well, and set the appropriate expire time.
Comments
Comment #2
aNickPlx commentedThis worked locally
Comment #3
yesct commentedjust a few white space changes. https://www.drupal.org/coding-standards#indenting
Comment #4
aNickPlx commentedMarking as duplicate of #2352009: Bubbling of elements' max-age to the page's headers and the page cache