Caching static files


I have a Gatsby site hosted at Netlify with manual deploy.

I have a static folder i my gatsby project so that I can host static files like images and other .html files.

But in my project and in the build folder i have deleted a file but I am still able to see it when i hit the URL but when i do a hard refresh its gone (and thats correct) but why is it showing up with on normal refresh every time and why is there in the first place? I have deleted it from my project…

Sounds like your browser is caching that file. Is your Gatsby site setting any custom Cache-Control headers in your _headers or netlify.toml file? That maybe why your browser is holding on to that file. You can read about how we handle caching by default here: Let me know if that makes sense.

Thanks for your reply Dennis,

Nope, I don’t have any custom Cache-Control headers. I don´t have an netlify.toml file in my project. And the file is still showing up…

The solution for me was:

configure in your gatsby-config.js

  resolve: 'gatsby-plugin-offline',
  options: {
    runtimeCaching: [
        urlPattern: /(static\/)/,
        handler: `networkFirst`,