-
Notifications
You must be signed in to change notification settings - Fork 814
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Service Worker Caching doesn't work stable in Safari Desktop [webpack-plugin] #2540
Comments
What you're describing—where you manually clear caches—sounds like you're deliberately entering into a situation in which the service worker's precached entries are deleted. The next time there's a service worker update detected, the |
Hi @jeffposnick , thank you for quick reply! I am sure, that makes sense. I am wondering if that is expected why this behavior presents only on Safari and not on other browsers? Nevertheless, most of the time Safari doesn't use SW cache to serve files, at least from my current experience. |
Shortly i will share a video to demonstrate the way this issue work on my side... having some internet issues |
This is example of the issue with one chunk This example of the issue with all chunks, Safari doesn't use SW cache after first load while Chrome does: |
@jeffposnick Please, let me know in case you need more info about this issue. Thanks! |
There are some details at w3c/ServiceWorker#1174 Different browsers behave differently with regard to the memory cache for images and also for other subresources. For images, the memory cache is checked before the service worker, and if there's a memory cache hit, a For other subresources, the behavior is not specified anywhere, and different browsers might do different things. There isn't a single "correct" behavior. Hopefully that, along with the explanation about what happens when you clear caches, explains what you're seeing. |
Library Affected:
workbox-webpack-plugin
Browser & Platform:
Safari Desktop 13.1.1
Issue or Feature Request Description:
Service Worker Caching doesn't work stable in Safari Desktop
Video demo of the issue
This is example of the issue with one chunk
homepage.d5e2937.js
available via SW cache in Chrome and not available in Safari after first pageload.https://share.getcloudapp.com/7KumxYbd
This example of the issue with all chunks, Safari doesn't use SW cache after first load while Chrome does:
https://share.getcloudapp.com/8Lu7Zv8Q
Public URLs at which the issue could be reproduced: https://www.roadandtrack.com/
Steps to Reproduce:
Use Safari desktop, turn on "network" tab developer utilities (to monitor cache source for loaded assets)
Open https://www.roadandtrack.com/ on both Chrome(or Firefox) and Safari
Empty cache, clear site data and reload https://www.roadandtrack.com/
On each pageload take a look at the source of cache for js files "with-hash-in-title" (webpack bundle chunks) during pageload.
Observe initial pageload (js chunks served from remote server)
Observe second pageload (js chunks served from SW cache)
Observe pageload after more refreshes of the page (js chunks served from browser cache, not from SW cache)
Expected Result:
On initial page load – all files that suppose to be cached via SW loading as usual from remote server (first load prepare cache)
After very first (non hard) page refresh – all "hashed" files serves quickly from SW Cache
After EVERY other (non hard) page refresh – all "hashed" files serves quickly from SW Cache
Actual Result for Safari Desktop:
After EVERY other (non hard) page refresh – all "hashed" files serve through browser cache, SW not working.
Fix attempts:
Upgrade Workbox to v5 -- didn't make any effect on the issue.
Different workbox configurations -- didn't make any effect on the issue.
Findings:
Based on workbox logs, http requests weren't passed into service-worker by Safari and served from a native cache instead.
The issue could be related to not full support of "MessagePort API" in Service Workers by Safari
Related issues found:
[iOS] Safari is using memory cache instead of service worker
Background sync fallback in Safari not working
iOS Safari keeps refreshing on the log in page if SW is active.
Additional bugs which could be related:
We also can see on Safari Desktop that indexedDB overpopulated with timestamps records for cached files (probably for expiration "maxAgeSeconds" plugin)
indexedDB looks like another posted issue: Background Sync - post requests with images are not stored in IndexedDB queue on Mobile Safari (iOS 13.3.1)
Webpack Config:
The text was updated successfully, but these errors were encountered: