3 ms·
Looks like you can achieve an equivalent effect with service workers, like this: 1. If no cookie is set, the server inlines all resources in the initial HTML,
by devit 6y ago
Looks like you can achieve an equivalent effect with service workers, like this:
1. If no cookie is set, the server inlines all resources in the initial HTML, along with the original URL in a data attribute if not content-hashed, and sets a cookie. Ideally, the inlining is performed so that base64 data is all together for better compression (this can be achieved by putting all scripts in the header and images in the header as CSS background-image values)
2. If JavaScript is enabled, a service worker is installed, and all the inlined resources are extracted, put in local storage (or in the browser cache if possible) and will be returned by the service worker
3. If JavaScript is enabled, the service worker keeps track of what is cached in the browser and modifies each request to send a bloom filter indicating these resources
4. The server later only inlines resources that are not cached by the client, using either the bloom filter if available, or using server-side tracking
As far as I can tell this has equivalent latency and bandwidth requirements to having server push plus cache digests, with the disadvantage of requiring JavaScript and slightly higher overhead, but the advantage of being more customizable.
- untog 6y agoThat's a lot more overhead. For one it requires you to spin up an entire JavaScript engine! I don't know if it was ever implemented but the beauty of doing this at the HTTP level is that (for example) it could be built into the networking layer of iOS or Android.