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

fix(gatsby-plugin-netlify): Do not cache static query data #26387

Closed
wants to merge 1 commit into from

Conversation

ksmithbaylor
Copy link

Description

I recently ran into some strange issues on my site that boiled down to queries that came from useStaticQuery being immutably cached. The underlying data fetched by the static queries had changed after a redeploy, but when the page loaded in browsers with a warm cache, the relevant components showed the stale data after a brief flash of the new data from the HTML (before JS had loaded).

Since static queries are given a deterministic query hash based on the query itself (not the query results) and written to /static/d/{queryHash}.json, the resulting file is cached indefinitely per the /static/* caching header.

This PR gives these files the same cache headers as the page-data.json files generated by Gatsby, since their purpose is similar.

@ksmithbaylor ksmithbaylor requested a review from a team as a code owner August 12, 2020 01:49
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Aug 12, 2020
@ksmithbaylor ksmithbaylor changed the title Do not cache static query data fix(gatsby-plugin-netlify): Do not cache static query data Aug 12, 2020
@bitmaks bitmaks added topic: netlify status: awaiting reviewer response A pull request that is currently awaiting a reviewer's response and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels Aug 12, 2020
@KyleAMathews
Copy link
Contributor

  1. very sorry about this bug
  2. excellent job debugging it!
  3. really appreciate you jumping in with a fix!
  4. @sidharthachatterjee already fixed the underlying issue by moving static queries to be written to the same directly as page queries so the existing caching rules people use keep working fix(gatsby): Move static queries to page data dir #26242

Cheers!

@ksmithbaylor
Copy link
Author

Perfect, thanks @KyleAMathews! I hadn't seen that update yet, sounds like it will fix my problem in a cleaner way.

@ksmithbaylor ksmithbaylor deleted the patch-1 branch August 12, 2020 05:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: awaiting reviewer response A pull request that is currently awaiting a reviewer's response
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants