4 ms·
What if on link hover, some javascript code notifies the server and the server pushes the page? When the user clicks the link the page will have already been do
by Town0 6y ago
What if on link hover, some javascript code notifies the server and the server pushes the page? When the user clicks the link the page will have already been downloaded. Would that not be possible and useful?
- divbzero 6y agoThere are libraries [1] that achieve what you describe. [1]: http://instantclick.io/ http://instantclick.io/ "InstantClick"
- Town0 6y agoYes and I'd describe them as unpopular hacks. Http2 push is not a hack.
- ioquatix 6y agoActually... I've implemented both client and server side HTTP/2 push and I'd say... it's a hack and we should deprecate it and remove it from the spec.
- Town0 6y agoHere's another idea: A user is expected to flip quickly through pages after a quick evaluation of each page. Server push makes flipping the pages instant, and the hit rare is 80% at least. Server push is extremely elegant, though it competes with more complex (scripting) approaches which the Valley hipster crowd adores. Usually that crowd lacks any hint of imagination, but they're not the only ones building technology solutions.
- earthboundkid 6y agoYes, TurboLinks is another library that does this: https://github.com/turbolinks/turbolinks https://github.com/turbolinks/turbolinks
- K2L8M11N2 6y ago“Notifying the server” is already done by browsers by just making a regular request. Prefetching links has been a thing for a while now. You don’t need HTTP/2 to do it.
- Town0 6y agoThis prefetching implementation is extremely simple fails gracefully. No complex browser APIs used to imitate a normal browsing experience. It all just works as it just goes through the caching system. I'd say this is nothing like existing prefetching implementations, which don't seem to be used much and no wonder.
- bawolff 6y agoFrom what i understand the push cache gets deleted the moment the http connection is closed, which to me makes it sound not the most suitable for this. Maybe just adding a rel=preload link tag dynamically would be better (do link tags work dynamically? I have no idea). Or just fetching with normal ajax and use a service worker.
- kevincox 6y agoThis is a really weird system you have devised. You are making a custom request to ask the server to push something to the browser. Browser: POST /preload?url=/next-page Server: PUSH /next-page Just cut out the middleman and make a regular request. Browser: GET /next-page Even better use browser preloading mechanisms so that the browser knows how to best prioritize them. In fact if you do it this way the browser can even start downloading subresources and prerendering the page.
- Town0 6y agoWeird? Having the html downloaded for the link you're about to click, and used by the browser if the user clicks on the link, is by far the most balanced and simple implementation of prefetching. Everything is handled by the http2 push technology. No excessive javascript nonsense, no altering the Dom, and no downloading and prerendering of everything behind a link you might not even click. Absolutely flawless and perfect enhancement to a browsing experience so long as the spec allows for this.
- Town0 6y agoAre you saying that a simple javascript http request would get cached by the browser and used if the user clicks on the link? If so my apologies. I don't make websites yet. That would indeed do the same thing that I'm proposing.