Repository navigation
Remove server roundtrip for window dimension code - #7
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In the proposed PHP homepage redesign (php/web-php#2105), we're linking to various URLs in the history of the project, which led me to: https://talks.php.net/show/oscon2002/
We're having an issue there where, sometimes, the slide pages get stuck re-loading forever.
Here's what I think is going on:
Slide pages under
/show/*specifically have this issue, because there's code trying to get the dimensions. When PHP sees nodimscookie,keyboard.js.phpemits a call toget_dims(), which ingetwidth.phpsets the cookie and then callslocation.reload()immediately.However.
AFAICT, the move to BunnyCDN has happened since anyone last really interacted with this code much, so no one noticed that the new CDN rules have slide pages coming back as
cache-control: public, max-age=3600withcdn-cache: HIT, cached regardless of cookies.So what that means for us is: if a cookie-less visitor visits and fills the cache, every visitor after that gets the copy containing the
reloadcall, and each reload returns that same copy (with thereloadcall) until the entry expires.To reproduce: with no cookies, request a slide (try with a cache-busting query string, e.g.
?cb=123) and theonloadhandler contains a call toget_dims();, while the cached copy of the same slide may or may not, depending on who populated it.Proposed fix:
Stop handling the window size through a cookie.
The size is only used in a few places that I could find, nearly all of them already JavaScript:
display.php(insideonClickstrings)keyboard.js.php,Replacing those with
window.innerWidth/window.innerHeightletsgetwidth.php, theget_dims()call, and the cookie parsing inshow.phpbe deleted, with no CDN change needed. It also fixeswinH, which is currently always0becauseshow.phpchecks$winHinstead of$mode->winH; I believe this will fix an issue that may otherwise present with our popups.Separately, slide pages still depend on the session for the selected display mode, so a cached slide can be served in another visitor's mode; that is out of scope here but worth noting.