简体   繁体   中英

Caching with Service Workers

I'm a bit confused implementing Service Workers . I don't know which files/urls I should cache. For example, my website has:

  • HTML, CSS and JS files;
  • PNG, WebP and SVG images/vectors;
  • CSS/JS cdn links for Bootstrap and others libraries.

Should I cache all of them? Is that the best thing to do?

Here is a link to SW's page, but I can't find anything there about what to cache, if everything, if only html/css/js, if also images...

Thanks in advance,
Luiz.

Service worker is very useful in caching the files in the browser itself. It is always recommended to cache only static files.

So any URL which is not generating dynamic data can be cached, just like AJAX calls should not be cached and HTML/CSS/JS/Images/SVG/Fonts/Video can be cached.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM