Skip to content

Handle your service worker cache properly or you will regret it

Today I learned,

when working with service workers, always make sure you handle the caching strategy properly. I was playing around with it to implement push notifications, didn’t pay attention to the caching strategy, and Workbox sets cache-first as default for precaching. The service worker kept serving stale assets from its own cache and users were stuck on the old version. I had a hard time working on that, but I’m glad I was able to solve it by doing a workaround that even AI didn’t think of. Always check what caching strategy your tools are using before shipping a service worker to production.

© 2026 All rights reserved.