Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[gatsby-plugin-offline] Can't exclude certain paths #13555

Closed
AurelioDeRosa opened this issue Apr 23, 2019 · 10 comments
Closed

[gatsby-plugin-offline] Can't exclude certain paths #13555

AurelioDeRosa opened this issue Apr 23, 2019 · 10 comments
Labels
type: question or discussion Issue discussing or asking a question about Gatsby

Comments

@AurelioDeRosa
Copy link
Contributor

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

@AurelioDeRosa
Copy link
Contributor Author

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

@Rajarml
Copy link

Rajarml commented May 20, 2019

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.

@wardpeet
Copy link
Contributor

cc @davidbailey00

@gatsbot gatsbot bot added the stale? Issue that may be closed soon due to the original author not responding any more. label Jun 10, 2019
@gatsbot
Copy link

gatsbot bot commented Jun 10, 2019

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’s 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! 💪💜

@wardpeet
Copy link
Contributor

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.

@gatsbot
Copy link

gatsbot bot commented Jun 22, 2019

Hey again!

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

Please keep in mind that I’m only a robot, so if I’ve closed this issue in error, I’m 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!

@gatsbot gatsbot bot closed this as completed Jun 22, 2019
@AnalogMemory
Copy link
Contributor

@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.

@wardpeet wardpeet reopened this Jul 17, 2019
@wardpeet wardpeet added not stale and removed stale? Issue that may be closed soon due to the original author not responding any more. labels Jul 17, 2019
@LekoArts LekoArts added type: question or discussion Issue discussing or asking a question about Gatsby and removed not stale labels Nov 27, 2019
@sidharthachatterjee
Copy link
Contributor

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!

@verekia
Copy link

verekia commented Feb 25, 2020

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

@byebyers
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: question or discussion Issue discussing or asking a question about Gatsby
Projects
None yet
Development

No branches or pull requests

8 participants