Reputation: 485
I am building my first Gatsby website. We host it on AWS S3. Also we use gatsby-plugin-offline
.
So far I'm not able to find a good solution on how to invalidate the cache after a new deployment.
Even if I manually de-register sw.js service worker and clean the site data via Devtools -> Application -> Clear Storage, the browser keeps loading a cached version (missing added pages, displaying old text content, etc.).
For deployment I use amplify
.
How do you invalidate an old cache when deploying a new build?
Thanks.
Upvotes: 5
Views: 1194
Reputation: 2346
Did you check the amplify configuration of gatsby-auth-starter-aws-amplify ? The offline plugin is active in this starter and it is the recommended starter for deploying gatsby to amplify.
Another solution would be to use the s3 plugin with aws-cli
Gatsby's caching docs explains caching rules for Gatsby to work well. Common problems are caused by HTML pages' caching (The cache-control header in HTML files should be cache-control: public, max-age=0, must-revalidate
)
Upvotes: 0