Google Chrome's prerendering create a new session
Added by Beat Brand about 10 years ago
Hello
I've a problem with the prerendering functionality of Google Chrome.
When you're typing a web address in the address bar, Chrome will begin to prerender that page if it's
confident about which site you're likely to visit (based on your local history).
(https://support.google.com/chrome/answer/1385029?hl=en)
If the application has different entry points, the browser first sends a request for the 'propably wanted' and as
second a request for the typed in url.
This behaviour leads in creating each time a new session and with this,
all initial actions like accessing a database, starting timers, json requests... will also be executed.
After typing in the correct url, the first session is still open until the session timeout occures.
My application is running on a small, embedded linux system with low performance.
Deactivating the prerendering functionality is not a real solution because the endusers uses default browser settings.
Is there a way how I can prevent my FCGI-Application to create a new application-object when there is 'only' a prerendering access?
Or a way to kill broken sessions?
Replies (7)
RE: Google Chrome's prerendering create a new session - Added by Stefan Arndt about 10 years ago
From my experience, Wt will only clean up a session if the browser sends some kind of "kill" signal (which isn't working so good because browsers fail to do that) - or you hit the timeout (or you do it yourself). You could introduce an own timer to detect newly created but inactive sessions - but this is more a hack.
On the other side, your application can only know if the request is to "prerender" a page, if Chrome actually tells you using some kind of flags.
Short search - Chrome does not: http://stackoverflow.com/questions/34562427/detect-google-chrome-page-prefetch
Well, thanks for pointing this out, because that could become an issue for me, too. Any more opinions on that?
RE: Google Chrome's prerendering create a new session - Added by Stefan Arndt about 10 years ago
More info on why Chrome does not use a header here on the issue tracker (wontFix explanation about half way through) - does not explain much but if anyone is interested:
https://code.google.com/p/chromium/issues/detail?id=86175
RE: Google Chrome's prerendering create a new session - Added by Beat Brand about 10 years ago
Thanks Stefan
It's a goot idea with the timer. I think, I'll try this 'hack' ;-)
RE: Google Chrome's prerendering create a new session - Added by Koen Deforche about 10 years ago
We probably need to fix this in Wt: if the page is in 'prerender' visibility state, then we should have a much shorter session timeout, until the page transitions to a visible state?
RE: Google Chrome's prerendering create a new session - Added by Stefan Arndt about 10 years ago
Sounds like a good idea, but keep in mind that there may be now way for you to distinguish a 'prerender' visibility state from a normal one, without some javascript as described in the issue tracker.
From what I read: Chrome will "guess" what you type into the search bar and load the site (let's say into an invisible window/tab). If this is not, what the user wants, the page gets dropped. Otherwise Chrome will "flip" the content to the current window, showing the page to the user, without notifying the server of a "real" page load.
So the only option I see is to add the timer hack (which will only work if javascript is enabled). But I could be wrong, since I don't know about Wt's bootstraping.
RE: Google Chrome's prerendering create a new session - Added by Beat Brand about 10 years ago
The point is, if the user is very slow in typing in the url, the session still starts...
Perhaps there is a way with jquery $(document).ready(){} ?
RE: Google Chrome's prerendering create a new session - Added by Koen Deforche about 10 years ago
Hey,
In the default deployment mode ('default bootstrap'), Wt first renders a small HTML page with JavaScript to sense the situation (browser support for various features, Javascript capabilities, etc...). This is the place where we could defer the loading of the site until the user really opens it. This is being run before the application is being constructed on the server.
Koen