DEV Community

Discussion on: The thing about service workers...

Collapse
 
dar5hak profile image
Darshak Parikh • Edited

Caching using headers is indeed a breeze, but it falls short in two scenarios:

  • When a user has zero internet connectivity, the site won't load unless every resource is cached. (Not tested, but I'm fairly sure.)
  • You cannot control cache headers when serving from a static host like GitHub Pages or Surge.

Service workers offer a lower-level caching mechanism that can bypass these limitations.

That said, if you can control your headers and don't plan on offline access (but are caching for perf improvement), headers are the way to go.