When an entity bundle has Rabbit Hole configured to redirect to a value of a field on the entity (using tokens) and “Page cache maximum age” under Configuration > Performance is set to anything but "", for example 1 minute - 1 day, the site fails to create cache control headers for specifying max-age for the cached page. This can result in unpredictable caching behavior, depending on how the browser chooses to handle the absence of the cache control header. For instance, the browser may end up holding onto the page longer than you would like, regardless of whether or not drupal invalidates the associated entities cache. Some browsers are better at handling the absence of cache control tags than others; firefox seems to do terribly when this header field is absent.
Steps to Reproduce
- 1. Turn on anonymous page caching. Set “Page cache maximum age” under Configuration > Performance anything but "", for example 1 minute - 1 day.
- Configure Rabbit Hole's behavior on an entity bundle (content type, media bundle) to issue a page redirect.
- Set the Redirect Path to the url defined by a field value using tokens (for example: [media:field_document:entity:url].
- Set the Redirect Path to the url defined by a field value using tokens (for example: [media:field_document:entity:url].
- Create an entity, A.
- Turn on Developer Tools within your browser of choice, and switch to the Network Tab
- As an anonymous user view entity A. Experience, the redirect as you intended.
- View the Page Headers; notice the missing Cache Control Header
- Repeat the same steps, but using a brand new entity, with rabbit hole disabled(skip steps 2 & 3).
- View the Page Headers; notice the missing Cache Control Header.
Issue fork rabbit_hole-2991799
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
freddya21 commentedIssue Reported
Comment #4
japerryThe originally reported bug is already fixed in current 8.x-1.x. I reproduced the exact scenario in ddev — token-based redirect ([node:author:uid]), cache.page.max_age = 300, anonymous request — and 301/302/303/307 all return
Cache-Control: max-age=300, publiccorrectly.However, there are some other issues found while investigating this, specifically:
The following MR fixes the above issues.
Comment #6
japerry