Open optimalisatie opened 7 years ago
This sounds like an awesome feature! +1 would love to see.
However, I would think this would be implemented in some sort of caching layer directly above http2 transport.
The http2-cache.js is meant to be that layer (eventually, when fully implemented): https://github.com/kaazing/http2-cache.js.
Suggest closing this and moving the issue there :-)
Cache-Digest is currently a draft for the official HTTP/2 spec. It controls what assets are pushed before they are pushed. It is not a cache layer and not a client side cache. The client will calculate a hash that is processed by the HTTP/2 server.
An example of the client side hash calculation can be found in the following library (a Service Worker that calculates Cache-Digest).
https://gitlab.com/sebdeckers/cache-digest-immutable
Cache-Digest could become part of the official HTTP/2 spec:
http://httpwg.org/http-extensions/cache-digest.html https://tools.ietf.org/html/draft-ietf-httpbis-cache-digest-02
Thanks, understand now. This story has two parts, support for the frame type AND an API exposed to use (send/receive) that frame type.
I would think the use of that frame (i.e. calculating the digest for the client and then using the digest on knowing what to push for the server) would be implemented in a caching layer above http2.js. Thus I would think the API only need to return a way to set/get that value. Thoughts?
I believe that only a Service Worker would be able to provide the functionality as it is able to include a custom Cache-Digest header to navigation related requests.
A Service Worker is like a client side proxy that captures requests and is able to modify them.
https://developers.google.com/web/fundamentals/primers/service-workers/
The Service Worker could detect what resources have been pushed so that a Cache Digest could be calculated based on previously pushed resources. This would make management more simple: it will simply calculate a hash for resources that have been pushed by the HTTP/2 server and that therefor are likely to be relevant, while ignoring the potential thousands of other files. An expire time could further restrict the complexity of the hash calculation so that it could become as efficient as possible. The example in cache-digest-immutable
does not use those techniques however they have been implemented in a first version of a Google PWA Service Worker that is part of the WordPress plugin Above The Fold Optimization. The source code is available on Github:
The Above The Fold Optimization plugin provides HTTP/2 Server Push optimization based on Cache-Digest. This is the reason that we are interested to help make it available. It will be a very big step forward for front end performance optimization.
Hi!
It would be nice if the Server Push implementation would support Cache-Digest. It will reduce both latency and bandwidth.
https://calendar.perfplanet.com/2016/cache-digests-http2-server-push/ http://httpwg.org/http-extensions/cache-digest.html https://jakearchibald.com/2017/h2-push-tougher-than-i-thought/