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.

103 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,120
  • 5
  • 35
  • 69
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,495
  • 9
  • 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
  • 4,430
  • 1
  • 24
  • 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
  • 4,430
  • 1
  • 24
  • 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
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
  • 1,903
  • 2
  • 18
  • 28
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
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
  • 161
  • 1
  • 11
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
  • 188
  • 9
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
  • 14,734
  • 16
  • 77
  • 155
2
votes
0 answers

Service worker for create-react-app does not ignore urls

I've read through a bunch of the docs/issues for create-react-app and am trying to have my service worker not serve a specific url. According to the comments in the ejected version of create-react-app new SWPrecacheWebpackPlugin({ // By default, a…
praks5432
  • 5,732
  • 22
  • 76
  • 138
2
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,250
  • 7
  • 28
  • 65
2
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
  • 8,391
  • 16
  • 45
  • 90
2
votes
0 answers

Service worker using sw-precache, webpack and react

I have some troubles trying to add a cache system with a service working using the sw-precache-webpack-plugin v.0.11.4. My idea is that the people can use the app offline. My app is in React v.15.5.4 and Node v.6.9.5, but there are some parts in…
Aral Roca
  • 4,205
  • 4
  • 41
  • 67
2
votes
1 answer

sw-precache, cache files with URL Parameters

I have a quick question. I'm building a PWA with Polymer and Lighthouse reports, that the manifest's start_url is not cached by the ServiceWorker. Since I want to track the users, which use the 'Add to homescreen' function, my manifest.json…