Cache
Posted4 months agoActive4 months ago
developer.mozilla.orgTechstory
supportivepositive
Debate
20/100
Cache APIService WorkersOffline Web AppsWeb Development
Key topics
Cache API
Service Workers
Offline Web Apps
Web Development
The Cache API is a powerful tool for making web apps available offline, and is being used in various applications to improve user experience.
Snapshot generated from the HN discussion
Discussion Activity
Very active discussionFirst comment
23m
Peak period
22
0-3h
Avg / period
6.2
Comment distribution31 data points
Loading chart...
Based on 31 loaded comments
Key moments
- 01Story posted
Sep 4, 2025 at 11:46 AM EDT
4 months ago
Step 01 - 02First comment
Sep 4, 2025 at 12:09 PM EDT
23m after posting
Step 02 - 03Peak activity
22 comments in 0-3h
Hottest window of the conversation
Step 03 - 04Latest activity
Sep 6, 2025 at 9:08 AM EDT
4 months ago
Step 04
Generating AI Summary...
Analyzing up to 500 comments to identify key contributors and discussion patterns
ID: 45128578Type: storyLast synced: 11/20/2025, 7:35:46 PM
Want the full context?
Jump to the original sources
Read the primary article or dive into the live Hacker News thread when you're ready.
I haven't been using service workers lately but I had some run-ins recently when writing some CF workers.
https://xkcd.com/1053
edit: op deleted his beg comment after it was flagged dead
I created an SRS based kanji learning app (https://shodoku.app/ https://github.com/runarberg/shodoku) hosted on GitHub Pages (meaning the app is a static HTML page) where all the dictionary data is stored as hundreds of thousands of json (and SVG) files. Storing these assets using the Cache API saves tens of thousands of round trips to the server in addition to offering a somewhat robust offline experience.
It's very powerful, which also makes it a footgun: you can end up with fetch() requests going out over the network, with server responses saying one thing, but the frontend receiving something completely differently.
As for examples, I believe Home Assistant uses it to cache pretty much every resource in the frontend pre-emptively so you can use the web UI even if your internet connection is down (but your connection to your home server isn't).
I run a guitar chord chart site[0] that uses cache to enable offline experience; any chord charts you view while online are then available offline thanks to cache. It works pretty great. You service worker intercepts HTTP requests and can first check the cache for cached request/responses.
[0]: https://messianicchords.com
... until you find someone who has very low cache available. Or cache gets evicted.
The browser does its best to manage disk space, but it may delete the Cache storage for an origin.
in a warning box.
(I've done so myself a few times)
If you prefer you can also clone and make a pull request using standard git tools.
My app works fine online or offline. If you're offline and you ran out of disk space and the cache got evicted, ok, you can't use my web app offline.
(And, if you're out of disk space, all bets are off. You're gonna have other, more significant problems beyond a guitar chord chart site not working offline.)
...things can be super useful without being flawless.
Pro-tip: Use Serwist (https://serwist.pages.dev/), don't learn Workbox. Serwist has beautiful Vite integration for preloading app chunks from a build manifest. Learn all the different caching strategies. Consider dynamic caching strategies, eg. switching between two strategies for a specific cache via messaging throughout the lifetime of the app. Deep breaths. Have a service worker kill-switch in case things go wrong.
then hate the modern internet >:(