[Common Issue] Making the most of Netlify's CDN cache

Our CDN derives much of its efficiency from files whose checksums don’t change between deploys.

For instance, in a blog, you usually write or update one article in one file, while the rest of the content remains unchanged. In this typical use case, we don’t need to re-upload and re-process these files, since our CDN already has them stored - no checksums have changed except the one file. This also means that your visitors’ browsers don’t need to re-download any files, since they already have a cached copy of the latest version (see this article for more details about how our CDN handles browser caching for more details).

If you see perpetual deploy summaries with many files uploaded, like this:

…then you are probably not leveraging our CDN well AND your site probably takes far longer to deploy than it ought to.

So let me guess - you’re seeing that kind of pattern in your deploys, right?

  • If it was intentional, could you tell us what change you are expecting with such broad effects? We may have some advice to refactor a little bit and speed up deploys and browsing a lot :slight_smile:

  • If it wasn’t intentional, perhaps your build process changes some filename which is included in each file? If so, don’t do that and your site will deploy much faster since we don’t need to reupload the files - EXCEPT that single changed javascript file - which our caching mechanisms that are documented here will appropriately force browsers to re-download since it changed - but without re-downloading all of your unchanged content as well!

A trick I use to “see what changed” is to download a copy of the deploy from its successful logs page. The icon pictured below will let you download a copy of that specific deploy.

Do this twice for two deploys that should be largely identical (e.g. 2 sequential commits to a branch), and then use the a “diff” utility the two to see what changed. I bet it is a very small number of lines per file - and I further bet that you can change your build script to not create different filenames and avoid the re-uploads and speed your site up for return visitors at the same time! :slight_smile:

3 Likes

Hi there,

Thanks very much for such a detailed reply. Sorry for my late response. We are using Gatsby which i think is making it look like all files have changed - even if they haven’t.

The pattern you have described is exactly what we are seeing.

I’ve tried using a couple of gatsby plugins to prevent this from happening. I’ll use the tip you’ve provided to try and debug whats going on.

Thanks,

Dave

1 Like