Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Persist URL fragment during client-side mobile redirection and guard against infinite redirect #5775

Merged
merged 2 commits into from
Jan 12, 2021

Conversation

westonruter
Copy link
Member

@westonruter westonruter commented Jan 11, 2021

Summary

Fixes #5767.

This fixes an issue which can occur when a caching plugin is failing to vary the cache by query parameters. This can result in cache pollution, where a non-AMP page is cached and served for both non-AMP URLs and AMP URLs alike, and vice-versa. When a non-AMP page is served for an AMP URL, mobile redirection can end up endlessly attempting to redirect to the AMP version, even though the user is already at the AMP URL. So the fix here is merely to check that the user is not at the AMP URL already. This fixes a symptom of a misconfigured caching plugin, although the underlying cache misconfiguration issue remains to be addressed by the site owner.

This PR also fixes a related issue I discovered where client-side mobile redirection was not persisting the URL fragment. For example, if attempting to go to /#colophon then redirection would result in the user going to /?amp=1 instead of the expected /?amp=1#colophon.

Before

before2.mov

After

after.mov

Checklist

  • My pull request is addressing an open issue (please create one otherwise).
  • My code is tested and passes existing tests.
  • My code follows the Engineering Guidelines (updates are often made to the guidelines, check it out periodically).

@westonruter westonruter added the WS:Core Work stream for Plugin core label Jan 11, 2021
@westonruter westonruter added this to the v2.0.10 milestone Jan 11, 2021
@github-actions
Copy link
Contributor

Plugin builds for 2861dff are ready 🛎️!

@pierlon
Copy link
Contributor

pierlon commented Jan 11, 2021

Oh #5776 amends this PR, I'll take a look at that also.

@westonruter westonruter merged commit 234be39 into develop Jan 12, 2021
@westonruter westonruter deleted the fix/client-side-mobile-redirection branch January 12, 2021 01:22
westonruter added a commit that referenced this pull request Jan 12, 2021
@pierlon
Copy link
Contributor

pierlon commented Jan 13, 2021

QA passed

The URL fragment is kept during client-side mobile redirection, as demonstrated below:

url-fragment-persistence.mp4

@westonruter westonruter added the Changelogged Whether the issue/PR has been added to release notes. label Jan 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelogged Whether the issue/PR has been added to release notes. Video Highlight WS:Core Work stream for Plugin core
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Infinite Looping when the AMP plugin is activated
3 participants