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
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
  • 8,908
  • 28
  • 103
  • 157
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,093
  • 2
  • 10
  • 21
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
  • 19,082
  • 25
  • 92
  • 158
1
vote
1 answer

How to Listen for Service Worker (sw-precache) Updates from Inside Angular 4

In the SW-Precache demo code, there's a line that logs to the console when "the old content will have been purged and the fresh content will have been added to the cache." It also says in the comments that this is a good time to let the user know…
brady
  • 145
  • 2
  • 6
1
vote
1 answer

sw-precache push notification listener

I would like to create my first PWA app and I want to use sw-precache. I would like to have push notifications in my app, but I don't see any option to add push notification and notification click listeners via sw-precache generate. Should I add…
Blejwi
  • 1,005
  • 2
  • 10
  • 25
1
vote
1 answer

Cache API and images from backend server in sw-precache with gulp

I'm very new to use sw-precache with gulp in my app. I've created web app done by angularjs and fetch information from our backend nodejs application. At that application, I've added sw-precache feature to make offline first application. one of api…
PPShein
  • 13,309
  • 42
  • 142
  • 227
1
vote
2 answers

swPrecache and CDN as proxy?

I am using swPrecache, for loading my static assets of my PWA, to support offline mode. It working great. My setup is something like: https://www.myexampledomain.com/myapp/ loads static index.html and which in turn loads uses swPrecache to load…
Ravi Gidwani
  • 198
  • 12
1
vote
1 answer

sw-precache offline mode not fetching js or css

Im using the sw-precache-webpack-plugin for my React progressive app, on offline mode I get the Template from cacheStorage, but its not fetching the css or js. Not sure where im going wrong. new SWPrecacheWebpackPlugin({ cacheId:…
Graeme Paul
  • 1,143
  • 1
  • 16
  • 30
1
vote
1 answer

sw-precache-webpack-plugin webpack service worker default template

I'm using the sw-precache-webpack-plugin to generate a service worker for my project, I can see all my fonts, js and css files in the cache storage but not the index / html file and its not working when i go offline. I also get a 'site cannot be…
Graeme Paul
  • 1,143
  • 1
  • 16
  • 30
1
vote
2 answers

Using sw-precache configured with runtimeCaching is not loading sw-toolbox

According to the sw-precache documentation https://github.com/GoogleChrome/sw-precache#runtime-caching including configuration for runtime caching for sw-precache should itself take care of including sw-toolbox for runtime caching of dynamic…
1
vote
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
  • 7,362
  • 50
  • 46
1
vote
1 answer

How to Change the default Cache First strategy to network first strategy in sw-precache?

Here is my gulp task : gulp.task('service-worker', ['clean:sw'], function (cb) { swPrecache.write(path.join(global.config.offlineRoot, 'sw.js'), { staticFileGlobs: [ global.config.offlineRoot +…
Sandeep
  • 121
  • 10
1
vote
2 answers

CDN Service Worker

I'm trying to set up a service worker using sw-precache to cache assets from CDNJS to be used offline. Unfortunately, this doesn't seem to be working. Here's what I have so far: Before any of the scripts are loaded in index.html:
LandonSchropp
  • 10,084
  • 22
  • 86
  • 149
1
vote
0 answers

Offline Ready using Service worker

I built an offline first app using the appcache a while ago and wanted to convert it to using the service-worker (my clients all use the latest chrome so I don't have any browser compatibility issues). I'm using sw-precache to generate a…
JakeHova
  • 1,189
  • 2
  • 15
  • 36