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
0
votes
1 answer

Should workboxJS replace usage of sw-precache?

Following the 1.0.0 release of WorkboxJS, should this be used as a replacement for sw-precache? From my limited experience it seems to include all the awesome from sw-precache' andsw-toolbox` and much more. In their own words: The next version of…
Kevin Farrugia
  • 6,431
  • 4
  • 38
  • 61
0
votes
1 answer

How to show custom 404 page using sw-toolbox sw-precache libraries for service-worker

I have an SPA which makes various http calls to get content from third party service and show content on the page. How do I configure /use sw-toolbox and sw-precache libraries, such that if http call fails due to being offline it shows a custom 404…
happy
  • 39
  • 6
0
votes
1 answer

How can a initialize sw-precache with all site pages

I would like to make an app available completely offline. ie user clicks a button (or not, this could happen automatically) while online and every page, including all dynamic pages, and assets on the site could be cached. I understand I would need…
riley
  • 2,387
  • 1
  • 25
  • 31
0
votes
3 answers

How to cache everything but content using sw-precache

I'm using sw-precache in a jekyll website to add offline capabilities with the following configuration: gulp.task('generate-service-worker', function(cb) { var path = require('path'); var swPrecache = require('sw-precache'); var rootDir =…
Carlos Martinez
  • 4,350
  • 5
  • 32
  • 62
0
votes
2 answers

Configure the sw-precache WebPack plugin to load a server rendered page as the navigateFallback route

consider the following scenario: My express server dynamically generates HTML for the "/" route of my single page application. I would like to re-serve this same generated HTML as the service worker navigateFallback when the user is offline. I'm…
Gavin
  • 6,495
  • 3
  • 21
  • 22
0
votes
1 answer

Caching entire folder in service worker

I have a build folder which is generated via webpack, any idea how i can cache the entire folder, i tried the following but to no avail self.addEventListener('install', e => { e.waitUntil( caches.open('notes').then(cache => { …
Nitish Phanse
  • 552
  • 1
  • 9
  • 16
0
votes
1 answer

Cache internal routes with sw-precache

I'm creating a SPA using vanilla JavaScript and currently setting up sw-precache to handle the caching of resources. The service worker is generated as part of a gulp build and installed successfully. When I navigate to the root url…
tonyedwardspz
  • 1,707
  • 2
  • 22
  • 45
0
votes
1 answer

How to cache new fetch requests in sw-precache

I am trying to use sw-precache to enhance the off-line experience in a web app. As I understand it, the library (and correct me if I am wrong) is to pre-cache all static assets. What about new requests? Say I want to cache the response of a new get…
Ali Hmer
  • 4,841
  • 3
  • 20
  • 13
0
votes
1 answer

Progressive webapp with shell cached still not behaving as desired?

I have used Sw-precache in my React app to pre-cache my built assets(i.e vendor.js, app.js and, icons). however, the result is less than desirable. On page reload my app assets are all fetched again(from service worker), but never the less…
jasan
  • 11,475
  • 22
  • 57
  • 97
0
votes
1 answer

How to get hosted or remote json files cached to enable app work well offline

I am building an app that is suppose to work offline. It's a video web app using angularjs and firebase. The app receives data from firebase database for instance in the service js file: .service('firebaseService', function ($http) { …
LearnToday
  • 2,762
  • 9
  • 38
  • 67
0
votes
1 answer

How do i check that sw-toolbox urlPattern handler strategy is working as designed?

I'm using sw-toolbox with sw-precache at runtime caching option. But when i visit the url and inspect the network in devtools it shows cached from service workers not from network first (as i desire). Maybe I just don't understand how these two libs…
jasan
  • 11,475
  • 22
  • 57
  • 97
0
votes
1 answer

Multiple requests are being made from service worker to cache a resource

As I'm working on building progressive web apps. We are facing weird behaviour for service worker. 1. Clear cache and unregister service worker 2. Go to www.example.com 3. Examine the network calls for resources (JS/CSS) Expected result: Only…
Vivek Pratap Singh
  • 9,326
  • 5
  • 21
  • 34
0
votes
2 answers

How to resolve Dynamic URLs dependencies through Service worker?

Though I am familiar with Sw-precache and Sw-toolbox libraries, Still puzzle on how to cater Dynamic Dependencies while building Progressive Web App using Angular. I have pre-cached bundle.js, bundle.css and some static templates for my application…
-1
votes
1 answer

Migrate from Google's sw-toolbox to Workbox SW (Visual Studio)

I used to use sw-toolbox for management of my service worker - small, simple, effective. Now that Google have released Workbox SW (which replaces sw-toolbox and sw-precache) I need to migrate, but am battling to find: a) single .js dependency for…
Jimbo
  • 22,379
  • 42
  • 117
  • 159
1 2 3 4 5 6
7