Coder Social home page Coder Social logo

netlify-plugin-gatsby-cache's Introduction

Netlify Build Plugin: Persist the Gatsby Cache Between Builds

Persist the Gatsby cache between Netlify builds for huge build speed improvements! ⚡️

Usage

Currently, there are two ways to install this plugin on your application:

Installing from Netlify UI

One-click install to add this to your Gatsby site

Installing from your project's code

You can also install it manually using netlify.toml. If you want to know more about file-based configuration on Netlify, click here.

Add the following lines to your project's netlify.toml file:

[build]
  publish = "public"

[[plugins]]
  package = "netlify-plugin-gatsby-cache"

Note: The [[plugins]] line is required for each plugin, even if you have other plugins in your netlify.toml file already.

How does it work?

This plugin determines the location of your .cache folder by looking at the publish folder configured for Netlify deployment. This means that if your Gatsby 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 Gatsby site is different, so build times vary widely between them, but one common slowdown in Gatsby builds is processing and transforming images. Gatsby 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 public and .cache directories need to be preserved between builds. That’s what this plugin does!

No Cache Cache Savings
* 231 GraphQL queries
* 1,871 images
* 224 pages
293207ms (build log) 72835ms (build log) 75%
* 5 GraphQL queries
* No image processing
* 32 pages
22072ms (build log) 15543ms (build log) 30%

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.

Want to learn how to create your own Netlify Build Plugins?

Check out Sarah Drasner’s excellent tutorial!

netlify-plugin-gatsby-cache's People

Contributors

davidosomething avatar ehmicky avatar jlengstorf avatar knpwrs avatar lucis avatar samouss avatar verythorough avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.