Skip to content
This repository has been archived by the owner on Jan 23, 2021. It is now read-only.

Option for caching fewer resources when Save-Data: on header is set #145

Open
ebidel opened this issue Jul 18, 2016 · 4 comments
Open

Option for caching fewer resources when Save-Data: on header is set #145

ebidel opened this issue Jul 18, 2016 · 4 comments

Comments

@ebidel
Copy link

ebidel commented Jul 18, 2016

For content heavy sites (images, videos, etc.), precaching can introduce increased bandwidth consumption for slower connections.

sw-precache should have an option where the sw respects the Save-Data: on header if it is set by the client and precaches fewer resources. How this opt-in actually works is open for discussion. Perhaps users could mark critical resources. Other resources listed in the precache list are deemed optional.

https://developers.google.com/web/updates/2016/02/save-data

@jeffposnick
Copy link
Contributor

I like it! And then we can continue serving the content cache-first once it actually gets requested from the network because it's used for the first time on a page.

(FWIW, this change to skip cache-busting when the developer indicates that they're properly versioning their resources will help cut down on the precache data transfer, too.)

@ebidel
Copy link
Author

ebidel commented Jul 19, 2016

Want me to take a stab? I need to get more familiar with the lib codebase.
Pointers are appreciated!

On Tue, Jul 19, 2016, 7:07 AM Jeffrey Posnick [email protected]
wrote:

I like it! And then we can continue serving the content cache-first once
it actually gets requested from the network because it's used for the first
time on a page.

(FWIW, this change
d06def1
to skip cache-busting when the developer indicates that they're properly
versioning their resources will help cut down on the precache data
transfer, too.)


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#145 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAOigO-Fr13Fo9BeOKzJcJK4ST1DzTwIks5qXNn_gaJpZM4JPQJK
.

@jeffposnick
Copy link
Contributor

If you want to dip your toes in, sure!

I'd imagine it would involve creating a new option and treating it in a similar fashion to staticFileGlobs, except that instead of using its matches to populate precacheConfig, you'd create something like a new optionalPrecacheConfig, which you'd then pass into the template rendering function.

And then in the template, you'd need an insertion point for the new optionalPrecacheConfig. Inside the install handler you could check the value of Save-Data: on header... but wait, that header is only set on incoming Requests within a fetch event, and isn't available within the install handler, which is where all the precaching is done. 😦

Let me ask around a bit if there are ways to detect the same information supplied by Save-Data: on before the first fetch event is made.

@jeffposnick jeffposnick removed their assignment Jul 19, 2016
@jeffposnick
Copy link
Contributor

See WICG/netinfo#42, which tracks exposing the information that we'd need to make that determination inside the install handler.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants