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
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
  • 5,455
  • 35
  • 99
  • 181
2
votes
1 answer

Service worker Failed to load resource: net::ERR_UNSAFE_REDIRECT

would you please tell me what i did wrong with my service worker installation, i have those errors appear in chrome console (see the image-1). The script resource is behind a redirect, which is disallowed. …
chebaby
  • 5,564
  • 42
  • 40
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
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

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…
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…
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

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,700
  • 2
  • 12
  • 25
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
  • 751
  • 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
  • 628
  • 2
  • 12
  • 24
1
vote
1 answer

Run "sw-precache" command from c#

I want to generate "service-worker.js" using sw-precache from command line (cmd.exe) I run this command and output is : Total precache size is about 145 kB for 35 resources. service-worker.js has been generated with the service worker contents. When…
Alex
  • 6,714
  • 26
  • 84
  • 140
1
vote
1 answer

sw precache - runtime caching for assets loading from different domain

I am using sw precache to manage my service worker. Let us say my site is abc.com and the service worker is running on this site and loaded by url abc.com/service-worker.js All the css and js are being loaded from different url for optimization…
1
vote
2 answers

How to use staleWhileRevalidate for workboxSW precache items?

workboxSW.precache is cacheFirst by default, is there a way to change its strategy? workboxSW.precache(myPrecacheItems); Or is there a way to define the cache name on precache items, so precache items can be overwrite by specifying route?
seUser
  • 1,063
  • 2
  • 10
  • 19
1
vote
0 answers

Create React App - video loaded with webpack is not included in URLs to precache

I'm using sw-precachevia create-react-app to enable my app for use offline. I have a video that is loaded via webpack, but I noticed that it is not included in the generated serviceWorker's precacheConfig array. How can I force webpack / sw-precache…
Raphael Rafatpanah
  • 15,663
  • 19
  • 73
  • 136