Problem/Motivation
Visitors accessing the site with a preview link are served cached content from Varnish.
Steps to reproduce
Reproduction requires an environment with Varnish configured. This is reproducible in Acquia Cloud.
1) Generate a preview link for a workspace
2) Access the preview link in an incognito or non-logged in browser
You will be served whatever version of the page is cached.
Proposed resolution
Consider having the preview controller set other cookie values / a session cookie to bypass cache.
Recommend VCL configuration that can act on the wse_preview cookie parameter.
Issue fork wse-3504084
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
j-vee commentedHad the same issue with Platform.sh
To fix this, I had to add the cookie wse_preview to the .platform/routes.yaml settings file as per https://docs.platform.sh/define-routes/cache.html
I'd imagine the solution will be similar for Acquia as well.
This should be mentioned in the readme somewhere for the future folks.
Comment #3
danflanagan8I have confirmed this buggy behavior on Acquia Cloud with Varnish. If anyone needs an immediate fix, we can always cache bust by adding a random query string to the end of the url. That's a lot to ask of previewers, though, especially if they're going to be clicking around to multiple pages during the preview. But in a pinch!
I like the idea of starting a session in order to bypass Varnish (or other reverse proxy caches). I made a patch that I tested in an Acquia Cloud dev environment. It seems to have done the trick.
I'm going to put in an MR. I'm going to start lazy and eschew DI. If the maintainer approves the approach, we could then polish it.
Comment #5
danflanagan8Comment #6
danflanagan8After some testing in the wild, we determined that the caching of the redirect was problematic. We don't want it anywhere in the Drupal cache or the browser cache, otherwise the session might not get started when the user tries the preview link.
Comment #7
amateescu commentedComment #8
amateescu commentedI've added preview auth providers in #3592750: Add pluggable preview authorization providers with CDN caching support, including one for Acquia that I wasn't able to test myself. I'd appreciate any feedback whether it works correctly :)