HTTP/2 Server Push and Service Workers: The Perfect Partnership

3 Comments

Comments are ordered by helpfulness, as indicated by you. Help us pick out the gems and discourage asshattery by voting on notable comments.

Got something to add? You can leave a comment below.

Russell Heimlich

“With just a few lines of code, you can start building powerful caching patterns.”

Hmm… what’s wrong with just sending assets down the pipe with far-future expire headers that are then cached locally for a really long time? The way you describe the service worker in this article it sounds like the same thing. I can see service workers being useful for offline viewing of a page and stuff like that. What am I not seeing? Sounds like a lot more work for the same result except it is on the client side.

Mantish

I’m not sure if I understand correctly, but HTTP/2 would always push all resources, even with the service worker.
Although it’s great for faster loading, it seems not very bandwidth friendly.

Brian LePore

@Mantish,

Unless the service worker cache storage check is implemented poorly by browsers (that is, it acts like HTTP 1 instead of h2) it should be transferring the same amount of bytes as it does now, only faster. With h2 it’s making the first load (and the check for files from offline) much faster. The service worker adds to the internal cache so the user perceives the page to load faster.

Now, if one only wanted to make the images and JavaScript faster with the SW, but not the original document, then the page will transfer more bytes with h2 as it would serve the document + additional images/JS parts that it would use in the initial request.

Unless I’m wrong about this entirely. If so then someone will hopefully correct me. :p

Impress us

Be friendly / use Textile