GoogleChromeLabs / sw-toolbox

[Deprecated] A collection of service worker tools for offlining runtime requests
https://developers.google.com/web/tools/workbox/guides/migrations/migrate-from-sw
Apache License 2.0
3.62k stars 331 forks source link

Emulate stale-while-revalidate? #138

Open jeffposnick opened 8 years ago

jeffposnick commented 8 years ago

stale-while-revalidate is an HTTP caching header that isn't widely honored by user agents, but might get some actual use "in the wild" in HTTP responses.

@igrigorik suggested that we might want to make sw-toolbox emulate stale-while-revalidate semantics when it's present. This would presumably only apply for any runtime strategy that involves a fetch(), but we'd have to give that more thought.

ithinkihaveacat commented 8 years ago

Browsers will probably implement this eventually (Chrome info) so this would need to work with and without native support.

stale-if-error would be interesting to implement too.

decrek commented 7 years ago

@jeffposnick I noticed at clients that having always fresh content is really important and that toolbox.fastest just isn't enough. I don't know what emulating stale-while-revalidate really means, but I created a stale-while-revalidate recipe with sw-toolbox. Would you be interested in a PR where I make this an actual strategy in sw-toolbox? Either way, what do you think about this approach? You can find it in this repo.