Gatsby: [gatsby-plugin-offline] Can't exclude certain paths

Created on 23 Apr 2019  路  10Comments  路  Source: gatsbyjs/gatsby

Description

I have my own website built with Gatsby which have some folders that should not be managed by it. For instance, I have a blog running on WordPress and some static HTML files that I want to be served as they are, without Gatsby kicking in. This is an example of the project's folder structure:

/
--- /projects <-- Gatsby
--- /speaking <-- Gatsby
--- /blog <-- WordPress
--- /demo <-- Static files to serve as they are

I know that I could port the WordPress stuff to Gatsby, but this doesn't solve the problem I see. On the Workbox documentation I've found the option which would probably solve this problem: navigateFallbackBlacklist. I'm trying to employ is as such:

{
  resolve: 'gatsby-plugin-offline',
  options: {
    navigateFallbackBlacklist: [/^\/blog/, /^\/demo/]
  },
},

However, when I try to specify it, the option seems to be completely ignored when the SW is generated. I believe this problem has something to do with #9907.

The issue I'm reporting is somewhat similar to #10559 and #10035.

Steps to reproduce

  1. Install gatsby-plugin-offline
  2. Configure it as follows:
{
  resolve: 'gatsby-plugin-offline',
  options: {
    navigateFallbackBlacklist: [/^\/blog/, /^\/demo/]
  },
},

If you want to repro, you can use my own website: https://github.com/AurelioDeRosa/audero

Expected result

Some paths should be ignored by the SW

Actual result

SW kicks in and when I try to navigate in a page under _/blog/_, I receive a 404 page.

Environment

System:
OS: Windows 10
CPU: (4) x64 Intel(R) Core(TM) i7-6600U CPU @ 2.60GHz
Binaries:
npm: 5.10.0 - C:\Program Files\nodejs\npm.CMD
Languages:
Python: 2.7.14 - /c/Users/AurelioDeRosa/.windows-build-tools/python27/python
Browsers:
Edge: 44.17763.1.0
npmPackages:
gatsby: ^2.3.25 => 2.3.25
gatsby-image: ^2.0.39 => 2.0.39
gatsby-plugin-google-analytics: ^2.0.18 => 2.0.18
gatsby-plugin-manifest: ^2.0.29 => 2.0.29
gatsby-plugin-offline: ^2.0.25 => 2.0.25
gatsby-plugin-react-helmet: ^3.0.12 => 3.0.12
gatsby-plugin-sass: ^2.0.11 => 2.0.11
gatsby-plugin-sharp: ^2.0.35 => 2.0.35
gatsby-source-filesystem: ^2.0.29 => 2.0.29
gatsby-transformer-sharp: ^2.1.18 => 2.1.18
gatsby-transformer-yaml: ^2.1.11 => 2.1.11

question or discussion

Most helpful comment

Did anyone figure out how to exclude paths? I don't see any documentation about this. @sidharthachatterjee, would you have an example on how to do that with the v3 of the plugin?

In my case I want to exclude logged-in routes, so for instance:

/home => offline
/about => offline
/app/* => do not cache offline

All 10 comments

Has anyone looked at this issue? It's a couple of weeks since I reported it.

For some reason, I need this feature too: excluding the first and starter page being cached by the sw in order to force the load of authentication connexion page.

cc @davidbailey00

Hiya!

This issue has gone quiet. Spooky quiet. 馃懟

We get a lot of issues, so we currently close issues after 30 days of inactivity. It鈥檚 been at least 20 days since the last update here.

If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!

As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contributefor more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! 馃挭馃挏

let me ping @davidbailey00 again :p he's busy with his exams so if he doesn't answer in a couple of days i'll look into it.

Hey again!

It鈥檚 been 30 days since anything happened on this issue, so our friendly neighborhood robot (that鈥檚 me!) is going to close it.

Please keep in mind that I鈥檓 only a robot, so if I鈥檝e closed this issue in error, I鈥檓 HUMAN_EMOTION_SORRY. Please feel free to reopen this issue or create a new one if you need anything else.

As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks again for being part of the Gatsby community!

@AurelioDeRosa did you ever figure how to blacklist specific directories?
In my testing, the service worker only cares about paths that Gatsby creates. I have a setup where other directories are in the same root as Gatsby and visiting them doesn't trigger the service worker to cache them.

Hey @AurelioDeRosa

Just took a look at this issue. This was resolved in gatsby-plugin-offline v3. We've gone ahead and upgraded you to v3 and opened a PR at https://github.com/AurelioDeRosa/audero/pull/37

Closing this issue for now. Thank you so much!

Did anyone figure out how to exclude paths? I don't see any documentation about this. @sidharthachatterjee, would you have an example on how to do that with the v3 of the plugin?

In my case I want to exclude logged-in routes, so for instance:

/home => offline
/about => offline
/app/* => do not cache offline

Any update on how to exclude paths for gatsby-plugin-offline v3? Not in the gatsby or repo page.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kalinchernev picture kalinchernev  路  3Comments

signalwerk picture signalwerk  路  3Comments

theduke picture theduke  路  3Comments

Oppenheimer1 picture Oppenheimer1  路  3Comments

timbrandin picture timbrandin  路  3Comments