Skip to content
This repository has been archived by the owner on Jan 23, 2021. It is now read-only.

have service worker ignore certain routes? #359

Open
Oscar-21 opened this issue Jun 13, 2018 · 1 comment
Open

have service worker ignore certain routes? #359

Oscar-21 opened this issue Jun 13, 2018 · 1 comment

Comments

@Oscar-21
Copy link

I have certain routes that I want to be network only. I have been adding this to my generated service worker file to accomplish that. Is there an option offered by this library that I can use so I don't have to remember to edit my auto-generated service worker file every build?

self.addEventListener('fetch', function(event) {
  // I have to add the following line every build
  if ( event.request.url.match( '^.*(\/storage\/).*$' ) ) { 
    return false;
} 
@Jodge
Copy link

Jodge commented Apr 18, 2019

You can create a customized copy of the default template service-worker.tmpl to handle the routes you want to ignore, then set the templateFilePath [String] option to your custom template file

With this, you will not have to remember to edit the auto-generated service worker file every build

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants