Questions tagged [sw-precache]

sw-precache is a JavaScript build tool used to generate a service worker file.

The sw-precache library is a JavaScript build tool. When properly configured, it will generate a service worker file that handles precaching a web app's local, static resources, serving those resources cache-first, and keeping the cached resources up to date.

sw-precache is frequently used in conjunction with sw-toolbox, to handle both precaching of local resources and runtime caching of dynamic resources.

sw-precache's Getting Started guide explains its usage in more detail.

104 questions
5
votes
1 answer

Service Worker: How to build "Fresh" version of website for each new deployment?

The Problem I'm having an issue with a website (built w/ the Polymer Shop template) in production that's serving up old versions of code despite my new and improved deployments. I'm using the Polymer CLI $ polymer build command along w/ the Firebase…
Oneezy
  • 4,881
  • 7
  • 44
  • 73
5
votes
1 answer

How to append custom code to the generated service worker file

I'm using Webpack and swPrecache. swPrecache generates a service-worker.js file for me and I now want to append custom code to the generated file. I created a Webpack plugin that appends the babel transformed code to the service-worker.js file, like…
Ben
  • 1,525
  • 11
  • 19
5
votes
2 answers

Using sw-precache with client-side URL routes for a single page app

How would one configure sw-precache to serve index.html for multiple dynamic routes? This is for an Angular app that has index.html as the entry point. The current setup allows the app to be accessable offline only through /. So if a user go to…
mkhatib
  • 5,089
  • 2
  • 26
  • 35
5
votes
1 answer

Does sw-precache activation of new service worker guarantees cache busting?

I am using sw-precache along with sw-toolbox to allow offline browsing of cached pages of an Angular app. The app is served through a node express server. One problem we ran into is that the index.html sometimes doesn't seem to be updated in the…
mkhatib
  • 5,089
  • 2
  • 26
  • 35
4
votes
1 answer

precacheAndRoute got error on addToCacheList

I have created PWA and implementef workbox using workbox-webpack-plugin. I got error when i tried to precache the files. the error that i got (see image below) Console output sw.js:1 Uncaught TypeError: e is not iterable at d.addToCacheList…
4
votes
2 answers

Precaching with service worker, why does it matter? What did I miss?

I was looking at service worker practices and workbox. There are many articles talking about precaching, workbox even provides special method precachingAndRoute() for just that. I guess I understand the conceptual difference between precache and…
4
votes
1 answer

Problems cache busting serviceworker index.html file

I'm using Google's SW Precache to generate the serviceworker for an Angular (currently v.4) app hosted on firebase. I'm using Angular cli to generate my distributed files. When it comes time to deploy my app, I use the following commands: ng build…
jloosli
  • 2,461
  • 2
  • 22
  • 34
4
votes
1 answer

Caching external resources with sw-precache

I'm trying to get sw-precache to pre-cache external CDN resources, but the generated service-worker.js doesn't contain the CDN url's in the precacheConfig array. This is what I have in my gulpfile: staticFileGlobs: [ …
zeosamaster
  • 43
  • 1
  • 6
3
votes
2 answers

Won't be precached. Configure maximumFileSizeToCacheInBytes to change this limit (PWA)

help me. I have a problem after running "npm run dev" warning appears : WARNING in css/app.css is 4.13 MB, and won't be precached. Configure maximumFileSizeToCacheInBytes to change this limit. What does the warning mean? Can anyone explain? And…
3
votes
1 answer

How to precache assets with names that change at every deploy using service workers?

We're working with Workbox to precache some assets of the "next" page, but our assets URL contains the date and the hash of the deploy. E.g. "/css/2019-05-15/f00ba5/home.css". The problem we're facing is how to pass the changing portion of URL…
verlok
  • 173
  • 7
3
votes
1 answer

React service worker add files to cache

Building the first React app based on create-react-app. It already have a service-worker.js in production build, but I need to add couple JavaScript (workers) files manually. These files are not included in the HTML and service worker do not cache…
Serge
  • 321
  • 3
  • 14
3
votes
3 answers

How to remove a service worker registered in previous deploy from users' browsers with the newly deployed version of site (Firebase)?

I've deployed a new version of my site (It was on Polymer, now on Vue.js) to Firebase over an existing project. I'm using default Vue.js template with Webpack (vue init webpack my-project) in the new project Now that I've deployed the new version,…
Un1
  • 3,874
  • 12
  • 37
  • 79
3
votes
0 answers

Ignoring certain Url path-names in Service Worker for Create React App

the url that is ignored by default in Create React App Service Worker is the following for firebase auth "__" urls, it is done like so: navigateFallbackWhitelist: [/^(?!\/__).*/] **using the same negative Regex method I tried adding to the array…
jasan
  • 11,475
  • 22
  • 57
  • 97
3
votes
0 answers

sw-precache: Deleted cache, FetchEvent error response

I am using sw-precache for adding offline support to a web app. My setup: Static website with CSS/JS/HTML Dynamic content is handled via custom indexedDB solution. Grunt task used generate the service-worker. sw-precache (4.0.0) used to cache ALL…
Ravi Gidwani
  • 198
  • 12
2
votes
1 answer

Precaching with Stale While Revalidate Strategy in Workbox

Question Is it possible to precache a file using a different strategy? i.e. Stale While Revalidate? Or, should I just load the script in the DOM and then add a route for it in the worker with the correct strategy? Background This is quite a weird…
Ben Carey
  • 16,540
  • 19
  • 87
  • 169