Netlify Build Plugin: Persist the Gridsome Cache Between Builds
Persist the Gridsome cache between Netlify builds for huge build speed improvements! ⚡️
What are Netlify build plugins? Check out the announcement page on Netlify.
If you don’t want to use the UI-based installation, you can install manually using
Add the following lines to your
[build]publish = "dist"[[plugins]]package = "netlify-plugin-gridsome-cache"
[[plugins]] line is required for each plugin, even if you have other plugins in your
netlify.toml file already.
This plugin determines the location of your
.cache folder by looking at the
publish folder configured for Netlify deployment (this must be set in your
netlify.toml in the
[build] section). This means that if your Gridsome site successfully deploys, it will be cached as well with no config required! 🎉
How much of a difference does this plugin make in build times?
Each Gridsome site is different, so build times vary widely between them, but one common slowdown in Gridsome builds is processing and transforming images. Gridsome is smart enough to check if these transformations have already been done and skip them, but in order to get that benefit in a build pipeline (e.g. Netlify) the
.cache directories need to be preserved between builds. That’s what this plugin does!
|_ 231 GraphQL queries
_ 295 images
* 295 pages
tl;dr: Repeat builds with lots of images will be much faster. With few or no images, the difference will be there, but it won’t be as pronounced.
*note: the above differences are cited from my blog's repo; if you would like to submit a PR to add additional application size/savings data, I will be happy to accept it
Want to learn how to create your own Netlify Build Plugins?
Check out Sarah Drasner’s excellent tutorial!
Thank you to @jlengstorf whose work this repo is forked from; jlengstorf/netlify-plugin-gatsby-cache.