Re:Rules of Thumb for HTTP/2 Push
by buro9 on Thursday August 04, 2016 @06:08AM
(#12224513)
I reduced Server Push to these rules for my HTML pages:
* Push only when I can guarantee that they don't have it in cache
* Push only assets included in the <head>
Which, for me, means I push a single CSS file for a page when I know that the visitor is a new visitor. After that, I never push again.
The implementation is essentially:
* For a HTML page request
* Check for the existence of a pushed=true cookie
* If cookie does not exist (new user/session) push the CSS needed
* And add a Set-Cookie for pushed=true with the same cache expiry time as the CSS resource
That's it.
Of course... if we could move away from sending the CSS for a whole site when people just request a page then I'd revisit this, but until then a single CSS file needs a single cookie and a single push.
* Push only when I can guarantee that they don't have it in cache
* Push only assets included in the <head>
Which, for me, means I push a single CSS file for a page when I know that the visitor is a new visitor. After that, I never push again.
The implementation is essentially:
* For a HTML page request
* Check for the existence of a pushed=true cookie
* If cookie does not exist (new user/session) push the CSS needed
* And add a Set-Cookie for pushed=true with the same cache expiry time as the CSS resource
That's it.
Of course... if we could move away from sending the CSS for a whole site when people just request a page then I'd revisit this, but until then a single CSS file needs a single cookie and a single push.