-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
service worker swallows requests for files added to public/ #3008
Comments
now that i'm reading the generated |
/cc @jeffposnick |
i've just checked, and if i sneak i would have expected any static file that is not explicitly cached to be ignored by the service worker, i've traditionally been using though i am welcome to the idea that this is all my fault. once i have a temporary workaround for my immediate problem i'll try to recreate the issue with a fresh cra. |
yeah so it happens there too. steps to reproducecreate-react-app service-work-me
cd service-work-me
echo '<!doctype html><title>oh no</title>' > public/404.html
echo '["some", "json"]' > public/mushroom.json
npm run build
npm i -g serve
serve -s build then:
(it sends down the contents of but in a browser that does not support service workers, perhaps this is expected or necessary behaviour because you don't know what is and isn't a route in the app. though as it seems this would require configuration of the though there is a precedent for convention here, the service worker ignores firebase urls. i will make mine ignore routes that have file extensions, as i will still want to be able to link people to files hosted there even if they've been on the site before. |
Thanks for repro steps! Leaving this to @jeffposnick to comment on. |
I believe that this is fundamentally the same topic as #2894 (comment) It's reasonable to expect that anything you navigate to that exists as a static file in @goldhand, it would be great if you could confirm, but I believe modifying the {
staticFileGlobs: ['./public/**/*'],
mergeStaticsConfig: true,
stripPrefix: 'public/',
} alongside the other options should do the trick. I can't test that out at the moment, but I could in a day or so, unless anyone else does first. |
you're quite right, @jeffposnick, this is the same topic. adding that config doesn't quite do the trick. those files are now included in the precache, with the perhaps surprising effect that they will all be downloaded and cached during the first visit to the site, but they are still not available by a direct navigate. though this seems to be because the public prefix was not stripped off |
@jeffposnick's config does do the trick, with {
staticFileGlobs: ['./public/**/*'],
mergeStaticsConfig: true,
stripPrefix: './public',
} |
Great, glad to hear that works. I think that would be safe to add to the default config, but it would be awesome to get a confirmation when @goldhand is around, because these are options that are specific to his Webpack plugin. I'm also not in a position to file a PR for a bit while traveling, so perhaps someone else will want to step in there... |
thanks for working on this while you're traveling, @jeffposnick ! i've filed a PR with your changes, with a note that it's waiting for confirmation from @goldhand. someone may also like to fix the language in the comment. |
Sorry for the delay @chee, your changes are 👍 |
Instead of precaching everything in |
@goldhand no problem ! thank you @gaearon there's some discussion of that here: #3024 (comment) in summary: that's what i would prefer, it would be much simpler if sw-precache took a i think the surprise in having every file you've put in |
Thanks for taking the lead on this, @chee. I'll chime in on the open PR regarding alternatives to precaching the entirety of |
I am having problems accessing |
@aaronshaf, what you describe is related to this PR and to #3248. Once #3248 is fixed and deployed, you should no longer see |
Fixed by #3419. |
Here's a quick fix for this.
I just commented the navigateFallback function. |
Is this a bug report?
i can't tell, i suppose not.
Which terms did you search for in User Guide?
"service worker"
explanation
on my blog, the posts are stored in a file called
posts.json
, which i keep inpublic/
.the route for printing out a handsome html list of posts data is
/posts
.the posts themselves are built from markdown files that live in, for example,
public/posts/an-example-slug.md
. the url for the react rendered version of thatpost is
/posts/an-example-slug
.a cute feature of that has been that if you would like to view the source of one of
the posts, you can just add
.md
to the end of the url and there itappears in all its monospace fancy.
i was working on some feature changes last night and this morning, and i've
upgraded
react-scripts
and have my setup working nicely with the service worker.except now the service worker jumps in between me and my
public/
file request.i'm just now realising it is also eating requests for my
feed.rss
andmanifest.json
and i'm beginning to wonder if i have done something terribly wrong.can you think of anything i can do without ejecting?
i suppose i can generate my own service worker based on the lodash template.
related
#2253
#2714
The text was updated successfully, but these errors were encountered: