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

Negation in navigateFallbackWhitelist #292

Closed
SvenSeemann opened this issue May 2, 2017 · 1 comment
Closed

Negation in navigateFallbackWhitelist #292

SvenSeemann opened this issue May 2, 2017 · 1 comment

Comments

@SvenSeemann
Copy link

Hello everyone, i'm trying to use sw-precache on my project, but im currently struggling with the navigateFallback and navigateFallbackWhitelist.

For my static assets everything works fine, but I have a resource wich is used to download files, which should not be served by the service worker.

So I have paths like /.js, /.css, etc., wich should be cached, but everything behind /attachments/someID/download shouldn't.
In my understanding I would need more something like navigateFallbackBlacklist (as negation is not supported anymore by glob).

@jeffposnick
Copy link
Contributor

Yeah, blacklisting vs. whitelisting is a sticky issue.

The values that you pass in are RegExp objects, not glob patterns, so it's not too bad to negate it:

{
  navigateFallbackWhitelist: [/^(?!.*attachments)/],
  // other options
}

(In the currently WIP successor to this library, we'll support both white and blacklists.)

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