http2server-push

How does HTTP2 server push know what do push?


Server push works by sending js, css, images etc. just after responding to a request, instead of waiting for the client to receive the html, parse it and request the resources, saving a round trip. But pushing js, css, images, fonts etc. for example.com/about when those same files already got downloaded by the client when it fetched example.com a minute ago is a complete waste of bandwidth, because the client already has those files.

Keeping state server-side for each request seems expensive, and that's cannot be how it's done, since HTTP is stateless. Presumably, the client would re-request the html on subsequent visits, to see if anything's changed.

How does the HTTP2-server know what files to push?


Solution

  • There are several techniques for that. The browser can for example reset the streams. Or cache digests can be used.

    Here is more information on that:

    https://www.shimmercat.com/blog/cache-digests/

    Just today some people are having an interesting conversation on cache digests:

    https://lists.w3.org/Archives/Public/ietf-http-wg/2016AprJun/0371.html