3 ms·
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 <
by buro9 10y ago
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.
- hyperdunc 10y agoThanks. I haven't explored HTTP/2 Push yet and this example looks like a good starting point.