Gatsby: Netlify-Gatsby Cache does not recognize page update

We have a Gatsby Project that pulls Data from a Strapi Backend and creates static content from it.

We have this page at Training für Erwachsene | Plan-F.info which lists all “Praxisbeispiele” that are linked with this page in Strapi. The code for the page is at plan-f.info/{strapiMeasure.slug}.tsx at develop · FixMyBerlin/plan-f.info · GitHub

Our issue is, that on a regular push Netlify uses the build in Gatsby Cache. The Gatsby Cache does – for some reason – not recognize that the page changed and uses the previous page. In this case, it was a page which hat 0 “Praxisbeispiele”.

Questions:

  1. How do I disable the Netlify-Gatsby-Build-Cache for this page. The project is not big so we could just run the whole build every time. But it looks like there is no way to disable the caching?
    (Gatsby on Netlify | Netlify Docs does not explain this, unfortunately.)

  2. Is there anything obvious that explains why the cache is not working?

Thanks

Hi welcome to the forums! To disable the build cache for your Gatsby project on Netlify, you can add a gatsby clean command before your build command in your package.json file. This will clear the Gatsby cache before each build.

Here’s an example of how to modify your build script in package.json:

"scripts": {
  "build": "gatsby clean && gatsby build"
}

This approach was mentioned in a thread where a user faced a similar issue and resolved it by adding the gatsby clean command before the build command.

2 Likes