Questions tagged [service-worker-events]

122 questions
2
votes
1 answer

replace asset in service worker with fetch event

I'm trying to hot switch the theme stylesheet with my service worker. I created a theme for Jekyll (to use with GitHub Pages), and wanted the ability to replace between dark theme and light theme ("turn off the lights") and make that…
2
votes
0 answers

Service worker "install" event downloads files again which should already exist in browser cache

Before adding a service worker and caching the app-shell, the outgoing requests for files related to the web-page (e.g. main.css, app.js, shims.js..) were cached by the browser. Thereby, any further request for these files returned the cached…
2
votes
1 answer

Identify Origin/Source of FetchEvent Request

Is there any way for a ServiceWorker to identify the source or origin of a no-cors/opaque FetchEvent.Request? Or can we explicitly pass identifying information/data from the HTML to the ServiceWorker that could be used to identify origins of…
AnthumChris
  • 4,779
  • 1
  • 19
  • 41
2
votes
0 answers

cross origin scripts are not including after implementation of fetch event in service worker

here is my code : var cacheName = 'app-cache-v2'; var filesToCache = [ 'wp-content/themes/ct/bootstrap.css', 'wp-content/themes/ct/bootstrap-1024.css', 'wp-content/themes/ct/bootstrap-1280.css', …
2
votes
0 answers

Service worker has the Fetch event but not firing

I am trying to fetch the cached files from Service Worker but the Fetch event is not firing in latest version of chrome.whereas I am getting "Fetch handler existence: EXISTS". Here is the response which i got using…
2
votes
2 answers

If statement for specific event.request

I have the following code in my service worker index.js to show all the event request urls: self.addEventListener('fetch', functin(event) { console.log(event.request.url); }); With this all the request url are listed in the console. What i need…
d8ta
  • 167
  • 1
  • 12
2
votes
1 answer

How to track current URL changes in service worker?

I want to track user's activities in my PWA. Is it possible to send a request to my server on each site impression with current URI? Scenario: User opens PWA -> request with current URI. User opens a subpage -> send request with current URI. My…
1
vote
1 answer

service worker: cached data again loads from server, fetch is not triggered

Hence manifest is deprecated, trying to implement service worker in express web application. and this is my project structure : app.js views > login > login.ejs public > lib css …
1
vote
0 answers

How to refresh service worker when new update is pushed on server

I have a react app created by craco, it have service worker registered. After pushing new build to server, user is still getting old data / build files as they are cached by service worker. How can i force refresh the webpage, or give popup to user…
1
vote
1 answer

service worker doesn't skip waiting state

I'm still doing experiments in order to master service workers, and I'm facing a problem, probably because of my lack of expertise in JavaScript and service workers. The problem happens when I want the new service worker to skipWaiting() using…
1
vote
1 answer

Updating an Angular PWA in a controlled manner: Questions

I've been playing around with angular's PWA. I got everything running as I wanted, but I still have some unanswered questions: The swUpdate.available observable randomly fires twice (at once). How come? What if I prompt the user with a dialog when…
Tim
  • 2,954
  • 7
  • 30
  • 64
1
vote
0 answers

Toggle Modal on notification click

I'm trying to make my service worker file trigger a bootstrap modal on push notification click - but I'm struggling to get it to work. I understand that the service worker can't access the DOM, so how can I trigger such an event such as a…
NetSpud
  • 27
  • 1
  • 5
1
vote
1 answer

Is there anyway to delete my users cache?

I made a sw.js file that caches my chat website so users can open in offline mode, however, the Service Worker file caused alot of issues including not being able to see new messages and alot of website crashes so I was forced to delete it. Sadly my…
user14387653
1
vote
0 answers

How to stop increasing cache memory on every refresh when we are using service workers

I'm trying to do some POC on service workers for my site. Assets are getting cached but on every refresh, the cache storage size keeps increasing. How do I stop it. here is my service worker…
Pioter
  • 383
  • 2
  • 5
  • 16
1
vote
1 answer

Service worker & client communication. Fetch Event finished

I am trying to communicate a Service worker with a client in a bidirectional way. My aim is to delegate the processing of the request to the client and come back to the service worker with a proper response. The sequence of steps are the…
1 2
3
8 9