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
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
  • 7,246
  • 32
  • 91
  • 156
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
  • 5,442
  • 8
  • 47
  • 78
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…
Nicolai Schmid
  • 1,022
  • 1
  • 14
  • 29
2
votes
1 answer

Application Cache Storage items have empty response?

I'm getting my preactjs website set up with service worker. Using the Sw-precache-plugin I'm just looking at the cache items it stores in the Cache Storage, and the entries I expected are all there but they have an empty response. I checked some…
StevieB
  • 6,263
  • 38
  • 108
  • 193
2
votes
2 answers

Using sw-toolbox with gulp

I read many tutorials about sw-toolbox and sw-precache. The doubt i am having is : When reading about sw-precache, i found out most tutorials are using gulp + sw-precache. Whereas in sw-toolbox case, i saw the example and syntaxes given only for…
1
vote
0 answers

workbox Cache processing does not work with PrecacheController in v6

I was using workbox5.14 (@nuxtjs/pwa) to precache the 'message' event by passing the URL to PrecacheController when received. (from workbox-window) At this time, PrecacheController.addToCacheList() would not execute the cache, and for some reason…
1
vote
1 answer

Workbox precache doesn't precache

I'm attempting to implement workbox to precache image and video assets on a website. I've created a service worker file. It appears to be successfully referenced and used in my application. The service worker: import { clientsClaim,…
1
vote
1 answer

Workbox: writing regular expression for url patterns

I am trying to precache routes. I have successfully precaches the homepage using workbox.precaching.precacheAndRoute(['/']); and this to match route for homepage workbox.routing.registerRoute( /^\/$/, new workbox.strategies.NetworkFirst({ …
1
vote
0 answers

Add custom service worker on VUE

I am working with VUE PWA and I am trying to add my own service worker. checking VUE works the service worker with the sw-precache plugin so I'm trying to import my file so when the build is done I add it and can work my own service worker but it…
1
vote
0 answers

Save files in cache with sw-precache and React

Does anyone know how I can cache my APP_SHELL files using sw-precache plugin and React? The application was created with the cra command and I have managed to read my own service-worker. For the build and to take my files I have the following…
OscarDev
  • 917
  • 14
  • 34
1
vote
1 answer

How to precache django html templates using a service worker

I am converting my Django project to a progressive web app, and i am trying to precache my my files for them to be available offline. My problem is, I dont know how to locate my templates (e.g. homepage.html, index.html) to precache them using my…
1
vote
1 answer

Issue generating Service worker with sw-precache in react

I have created a react app using create-react-app. Then I decided I need to edit/update the service worker code as per my need. I am trying to build the app now using sw-precache (as its supposed to help building the custom service worker and…
Shibasis Sengupta
  • 629
  • 1
  • 6
  • 21
1
vote
2 answers

WorkboxSW constructor throws error Undefined

In my service worker file, I am using this code: importScripts("https://storage.googleapis.com/workbox-cdn/releases/3.0.0-beta.2/workbox-sw.js"); const workbox = new WorkboxSW(); But I am getting error Uncaught ReferenceError: WorkboxSW is not…
Amit Singh
  • 1,790
  • 3
  • 17
  • 27
1
vote
0 answers

In a Service Worker install listener, why does fetch return TypeError: Failed to fetch?

Using the sw-precache utility, I created a service worker that works if I refresh the page. But initially, the fetch call returns TypeError: Failed to fetch on a file which seems to cancel the rest. Refresh gets a few more files, refresh a few more…
neonguru
  • 759
  • 6
  • 16
1
vote
1 answer

sw-precache not updating and taking only cached data

Iam trying to implement networkfirst strategy using sw-precache. Now iam able to cache the data and able to serve from offline. If i change the data (i.e: changed the header from 'hello' to 'Welcome') in page not get reflecting it always taking the…
Harish Karthick
  • 710
  • 2
  • 12
  • 26