| Summary: | request gets fetched from memory cache instead of service worker after second refresh | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Giorgi <giorgi.lagidze> |
| Component: | Service Workers | Assignee: | Nobody <webkit-unassigned> |
| Status: | NEW --- | ||
| Severity: | Critical | CC: | cdumez, webkit-bug-importer, youennf |
| Priority: | P2 | Keywords: | InRadar |
| Version: | Safari 13 | ||
| Hardware: | Mac | ||
| OS: | All | ||
|
Description
Giorgi
2020-04-03 06:27:45 PDT
Hi Giorgi, Your observations are probably correct. The typical load flow is: Web page start a load -> Memory Cache check -> Service Worker Check -> Network Cache check -> Network load. If there are important resources you want to always return from service worker, the best way to do it would be to use Cache-Control on the response returned by the service worker since the Memory Cache will use these. Note that the memory cache improves the page load since the resources are in process and some of the resources are pre-processed for faster reuse like images. Would you be able to describe more precisely the issues this behavior might cause? Question 1) It's really interesting why the same thing doesn't happen on chrome and what's the reason they decided not to use this flow. Of course, they use memory cache but if there's service worker in play, service worker starts to be in full control and assets don't get returned from memory cache in this case. Question 2) Exactly which Cache-Control attribute would you use in this case ? (In reply to Giorgi from comment #3) > Question 1) > > It's really interesting why the same thing doesn't happen on chrome and > what's the reason they decided not to use this flow. Of course, they use > memory cache but if there's service worker in play, service worker starts to > be in full control and assets don't get returned from memory cache in this > case. Memory cache is not yet standardised so it is not surprising to see differences in that area. > Question 2) > > Exactly which Cache-Control attribute would you use in this case ? I would probably use something like must-revalidate. The service worker would always get the request. The service worker could return a 304 to make use of the memory cache entry. |