I like to do high fives, take photographs and make cool things with Ruby and JavaScript. You can also find me at Instagram, Github and Twitter.

Cache Gatsby builds on Netlify

When I started moving this site from Jekyll to Gatsby I noticed that my deploys to Netlify was very slow. Mostly because I have a lot of large photos that need to be converted and optimized to different sizes. I experienced deploy times over 10 minutes and thought that there must be something to do to speed things up.

When I was using Jekyll I just dumped my photos cache inside the node_modules directory and I thought that I just could do that now too. But it felt dirty. And hacky.

So I search the Netlify documentation but couldn't find anything about adding files to a cache between builds until I stumble upon a comment on StackOverflow (or was it on a Github issue?) that mentioned an undocumented cache folder and that someone already had built a Gatsby plugin that simply caches the Gatsby output in that Netlify folder. A piece of cake!

  1. Install the addon by running: yarn add gatsby-plugin-netlify-cache
  2. Add 'gatsby-plugin-netlify-cache' to the plugins list in your gatsby-config.js file.