Last reviewed in August 2021.
While the topic of caching effectively is complex, Netlify’s solution is designed to be automatic and worry-free. It shouldn’t require any special configuration or build tools like cachebusting or service workers to deliver an optimal experience.
So what can go wrong? Some cachebusting techniques can make your site build and load more slowly. Scarier still, modifying Netlify’s default caching settings can break the atomic rollbacks and deploys which are some of the coolest things about Netlify’s CDN. So, you’ll want to check any custom configuration to override the defaults with some experts (right here in this thread), lest your next visitor accidentally get stuck with an out of date index.html cached in their browser for a year! Never fear - most folks won’t need to change the default settings which are designed to be safe and fast.
I made a pretty bold claim in the last paragraph - that cachebusting would make your site SLOWER on Netlify’s CDN. That’s counterintuitive, but it is true. Here are two ways that happens:
- The way Netlify caches, when you change a filename with every build, that means the browser can never reuse its cache for the old filename, since it isn’t smart enough to know this other filename’s cache should be checked!
I wrote up this article about how Netlify caches for those who are interested in more in-depth details; feel free to ask questions about it in this thread. I’m excited to keep working making this post as useful as possible, so if you have feedback, please let me know!