Safari Service Workers and the Cache API: Can Offline Caches Survive Between Sporadic Visits?
0 reputation · 23 Nov 2023, 20:39 UTC
A low-traffic Progressive Web App is planned to serve its app shell and static assets through the Cache API so that occasional visitors load quickly and the origin handles fewer requests. Safari supports both Service Workers and the Cache API, so the offline-first pattern appears applicable.
The uncertainty sits at the boundary between the two features. Safari terminates idle service workers after roughly five minutes, and Cache API entries share a storage quota with other site data that can be evicted under pressure. Periodic Background Sync is not implemented in Safari, so caches refresh only when a user opens the site. For visitors who return days or weeks apart, it is unclear whether cached content reliably survives between sessions on current iOS and macOS Safari releases.
Open questions
- How do Safari's service worker termination and Cache Storage eviction interact for a site visited only occasionally — will cached assets still be served on the next visit?
- Does requesting persistent storage through the Storage API change Safari's eviction behavior for Cache API entries?
- How can cache retention be measured across visits on iOS and macOS Safari, given that eviction thresholds are not documented in detail?