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

What is the best approach to precache static resources?

We are trying out sw-precache to allow pre-caching of all static resources. We are just thinking which approach to follow for precaching versioned resources which have MD5 fingerprints in their filename. First solution could be to using sw-toolbox…
Vivek
  • 33
  • 4
1
vote
1 answer

Cache busting through sw-precache on already versioned bundle files

I am using sw-precache to allow pre-caching of all static resources of an Angular app. I understood the sw-precache concept of versioning by calculating the MD5 hash which is used to determine whether the file has changed or not. But I'm wondering…
Vivek Pratap Singh
  • 9,326
  • 5
  • 21
  • 34
0
votes
0 answers

Workbox precaching does not work with cross origin requests

I'm using the precacheAndRoute() function to precache a bunch of assets passed to a service worker by the InjectManifest() function of the workbox-webpack-plugin plugin. This works great, but all of these assets are hosted on a CDN, which means that…
Egon Olieux
  • 709
  • 1
  • 10
  • 18
0
votes
2 answers

Why is my Workbox GenerateSW showing my offline page while connected?

I'm trying to setup my offline page using Workbox GenerateSW() and running into an issue where on the first load after I clear site data and hard refresh displays my homepage, but on subsequent loads I am getting the offline page I set up even…
0
votes
1 answer

Workbox precache : Based on user type

I don't want to preCache for all users but only for members. I want to do this to avoid unnecessary load on the server and unnecessarily caching for one-time visitors. So when the visitor logs in, I send a message to the service worker. In the…
rethna2
  • 11
  • 3
0
votes
1 answer

How to generate predefined manifest with versioning using workbox-build for Service Worker

I'm trying to configure workbox-build to create a service worker (generateSW) or inject a manifest (injectManifest) to an existing service worker based on a list of predefined URLs instead of a pattern match in order to preCache specific resources…
0
votes
1 answer

PWA - empty service worker precache runtime

I'm developing an audio-based PWA and, since I'm not familiar with this technology, I have a couple of doubts regading the cache management and invalidation in the service worker. The application need to work offline, that I covered using a SW…
0
votes
1 answer

import workbox from local v5 in webpack-plugin

As we now in version 5 of workbox, the importWorkboxFrom config is removed, but if we are using injectManifest how we should import workbox localy? Is the only way in using importScripts with…
SayJeyHi
  • 1,559
  • 4
  • 19
  • 39
0
votes
1 answer

Why Precaching with fixed urls in manifest?

I was reading about precaching with service workers and i ended up with this precaching. I cant understand why it uses fixed urls with hashes. They must be created dynamically every time a file changes. So whats the point of putting them manually…
0
votes
1 answer

CRA precache fails because of .LICENSE extension

So, we have a situation where in production the precache is failing on our PWA because of a weird .LICENSE file on our server that is giving us 404 specifically an error like this uncaught (in promise) bad-precaching-response:…
0
votes
0 answers

Vue + SWPrecacheWebpackPlugin - app.js is not cached

I'm trying to implement a service worker for my website. I used SWPrecacheWebpackPlugin with vue and registering and so on works well. Somehow it doesn't cache all files, in this case I guess the most important app.js file. When I'm online the file…
movsky
  • 641
  • 5
  • 22
0
votes
1 answer

precaching over 1000 assets damages performance

I'm using Vue CLI PWA workbox plugin mode. My app has more than 1000 assets, and precaching them results in very bad performance. Please, check it out: https://nikudu.com/ Is there a way to precache files more specificly? For example, precache files…
0
votes
1 answer

How to configure Service Worker with React to prevent Uncaught Syntax Error on new deployments at AWS CloudFront

I've been reading SO posts and Github issues for the past few days on this topic and I still can't seem to find a combination that works for my setup. Hoping that someone can point me to a specific solution. Here's what's going on. I'm using…
0
votes
1 answer

Uncaught promise DOM exception in service-worker.js

Service worker registered successfully but I'm still getting the above error in chrome.
0
votes
1 answer

How can I configure Cache then network with SW Precache?

I have only found two options that accept this plugin that are cacheFirst and networkFirst but I can not find the option for Cache then network to get updates. { urlPattern: /^https:\/\/mlm-s2-p\.mlstatic\.com/, handler:…