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

Static query not invalidating hash #26135

Closed
herecydev opened this issue Jul 30, 2020 · 7 comments · Fixed by #26242
Closed

Static query not invalidating hash #26135

herecydev opened this issue Jul 30, 2020 · 7 comments · Fixed by #26242
Assignees
Labels
type: bug An issue or pull request relating to a bug in Gatsby

Comments

@herecydev
Copy link
Contributor

Looking at the guidance on caching (https://www.gatsbyjs.org/docs/caching/#static-files) I think the recent changes to static queries isn't correct with this. @sidharthachatterjee I don't know if this is something you can answer?

The guidance is:

All files in static/ should be cached forever

However the .json files that are output to the static/d folder look like a hash of the query (schema?) and not of the query result. Images are requested like /icons/icon-512x512.png?v=6097298229b47b2e2010b1492c6fee40, where the v seems to be a hash of something that rotates when an image has changed.

Is this ?v= supposed to be applied to the static/d/.json files as well?

Steps to recreate

  1. Create gatsby-starter-default
  2. gatsby build
  3. Observe static/d/ folder
  4. Change siteMetadata title, for example
  5. gatsby build
  6. Observe static/d/ folder, it hasn't changed
@herecydev herecydev added the type: bug An issue or pull request relating to a bug in Gatsby label Jul 30, 2020
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Jul 30, 2020
@sidharthachatterjee
Copy link
Contributor

Excellent issue @herecydev

We were just discussing this internally last night and I was about to update the documentation and create an issue. You beat me to it, haha. I'll update the documentation. I think this needs a two part solution:

  • Short term: We add public/static/d as an exception to the caching rules
  • Long-ish term: We switch the location for static queries into public/page-data/static/d

@sidharthachatterjee sidharthachatterjee removed the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Jul 30, 2020
@sidharthachatterjee sidharthachatterjee self-assigned this Jul 30, 2020
@herecydev
Copy link
Contributor Author

Short term: We add public/static/d as an exception to the caching rules

I think this needs to be broadcast well; I would expect a lot of people have that cache rule in place. It's the sort of thing you wouldn't bother checking periodically as well.

Long-ish term: We switch the location for static queries into public/page-data/static/d

Seems sensible, and would "just work" for everyone who's setup blanket rules

@disintegrator
Copy link
Contributor

Just got bitten by this :). We enabled a new locale in Contentful but since the static queries didn't change the resulting json files remained in the browser disk cache and were used instead of fetching updated ones. We're seeing a few issues and caching anomalies because of this such as menu items popping in and out.

@sidharthachatterjee
Copy link
Contributor

sidharthachatterjee commented Aug 6, 2020

We switch the location for static queries into public/page-data/sq/d

Fix published in gatsby@2.24.33

@ibraheemdev
Copy link

When did this. become an issue? Was it a result of a recent update? Because I had no issue with the static hashes until just recently

@herecydev
Copy link
Contributor Author

@ibraheemdev 17 days ago, from this pull request: #25723

@danielmgzzg
Copy link

danielmgzzg commented Oct 12, 2020

Guys, thank you so much for fixing this issue. I just wish we had found it earlier in the docs or something we have been clueless for months and tried all sort of things until we looked closely at the .json from the static queries and searched for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug An issue or pull request relating to a bug in Gatsby
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants