Persistent storage between deployments


I am using Netlify to host a gatsby website that is a PWA and offline-friendly (using gatsby-plugin-offline). Whenever I update my website, a lot of the old assets are removed. Assets like JS bundles, CSS, and media. When people then come back to the website after an update, a lot of the website breaks until the service worker has updated and they have refreshed the tab. Not a great user experience.

This isn’t a Netlify problem, it can happen on any platform. Previously I solved this on other platforms by uploading my assets to something like S3 and then referencing the files from the website there. However, I wanted to keep everything inside Netlify and I can’t find the best solution for this. I just need persistent storage that I can write to, or to persist storage between builds. What is the best solution with Netlify?

Many thanks!

Yup, this is a pretty common use pattern. So common we wrote up the best practices around it:

Take a look and let me know if you can adapt to that workflow. If not, I don’t have any better suggestions, but your use case could help inform our future developments around this workflow so I am asking for a reason :slight_smile:

Ahh yes, I see thanks! Some tools do not allow you to disable hashed filenames sadly. And if they did, the use-case there doesn’t help my problem since I have lazy loaded components which may get removed on the next deployment. So somebody navigating to an older page being served from cache, will try and lazy load a component, and it will fail. This is a common pattern on modal components, or for lazy loading some scripts that only happen when you click on a button but have large dependencies.

I was thinking of something like the workflow described in the Gatsby docs about Asset Prefixes ( I was imaging using Netlify as a asset server too, then I don’t have to configure AWS and Netlify, and it would be great to keep everything in Netlify :smile: