Open ithinkihaveacat opened 8 years ago
Yeah, the interaction between service workers, fetch, and the browser's "normal" HTTP cache is a frequent source of confusion for developers.
Would you prefer fetchFirst
/fetchOnly
/cacheThenFetch
etc.?
The existing terminology was, I believe, inspired by @jakearchibald's bible, so mentioning him in to see if he has thoughts.
If resources are being served with considered cache-control headers,
toolbox.networkFirst
is probably the correct strategy to use. This probably should be called out in the documentation. (Similarly, the docs should mention thatnetworkFirst
(and evennetworkOnly
) will not necessarily force all requests to go over the network.)For example, if a particular resource is served with
cache-control: max-age=3600
, then with thenetworkFirst
strategy, this will not actually hit the network until 3600 seconds have elapsed, sincefetch()
goes through the browser's cache. (I think thenetworkFirst
is equivalent to astale-while-revalidate
value of infinity.)