Problem/Motivation

When generating a preview link using WSE (Workspace), the link displays data from the live workspace instead of the intended preview workspace data. This issue occurs specifically when working with Pantheon hosting.

Steps to reproduce

1. Create or modify content in a preview workspace
2. Generate a WSE preview link for the workspace
3. Access the generated preview link
4. Observe that the content shows live workspace data instead of preview workspace data

Proposed resolution

- Implemented Pantheon's cache control documentation: https://docs.pantheon.io/cache-control
- Tried setting NO_CACHE headers
- Attempted Cache-Control header modifications
- Issue persists despite cache-related troubleshooting

Remaining tasks

Create a patch? It looks like Workspace context is not being properly maintained through the preview URL, need to investigate more.

User interface changes

N/A

API changes

N/A

Data model changes

N/A

Issue fork wse-3544287

Command icon 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

rishi kulshreshtha created an issue. See original summary.

dandaman’s picture

Rishi, it looks like others are having the same issue on other hosts: #3544287: Live workspace data is shown instead of preview workspace

Have you tried applying the changes they have proposed? Does that fix the issue for you?

rishi.kulshreshtha’s picture

Similar issues have been reported by an Acquia Cloud user in this https://www.drupal.org/project/wse/issues/3504084 issue. In the same thread, another user on Platform.sh resolved the problem by adding the wse_preview cookie as described in Platform.sh's cache documentation https://docs.platform.sh/define-routes/cache.html

However, I don't believe this applies in my case, as both the NO_CACHE and wse_preview cookies are already present during the initial redirect and subsequent requests. Also, the patch provided in that issue did not resolve the problem on my end.

I additionally attempted a custom solution to force cache bypass behavior using an EventSubscriber that sets the following:

NO_CACHE=1 cookie
Cache-Control: no-cache, no-store, must-revalidate, max-age=0
Pragma: no-cache
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Custom debug header: X-WSE-Preview-Cache-Bypass: 1

Unfortunately, none of these approaches has worked so far.

rishi.kulshreshtha’s picture

Status: Active » Needs review

Because of the way the cookie is named, this module isn't compatible with the Pantheon.io hosting platform. However, according to Pantheon's technical documentation, this can be easily fixed by choosing a cookie name that their system supports.

rishi.kulshreshtha changed the visibility of the branch 2.0.x to hidden.

rishi.kulshreshtha changed the visibility of the branch 3.0.x to hidden.

shasha821110’s picture

StatusFileSize
new1.81 KB

#9 works as expected in my testing. For Drupal 10 environments, apply the following patch after step #9.

rishi.kulshreshtha’s picture

Version: 2.0.x-dev » 3.0.x-dev
Status: Needs review » Needs work
Issue tags: +Needs tests
rishi.kulshreshtha’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests
StatusFileSize
new25.99 KB

All tests have successfully passed. Details can be found at: https://git.drupalcode.org/issue/wse-3544287/-/pipelines/760657. This is now ready for review. Attached is the patch for use.

rishi.kulshreshtha’s picture

StatusFileSize
new26.32 KB

This patch is compatible with the 2.x release (Drupal 10 compatible).

amateescu’s picture

Project: Workspaces Extra » Workspace Preview
Version: 3.0.x-dev » 1.0.x-dev
Component: Workspace Preview » Code

WSE Preview has been promoted to a standalone project.

chrisfromredfin’s picture

Confirming that this 10.x port works for us. We'll move to using workspace_preview with patch there.

amateescu’s picture

Status: Needs review » Postponed (maintainer needs more info)
Related issues: +#3592750: Add pluggable preview authorization providers with CDN caching support

I've added preview auth providers in #3592750: Add pluggable preview authorization providers with CDN caching support, including one for Pantheon that I've been testing on their free tier. I'd appreciate any feedback whether it works correctly :)