Skip to content
Caches your Gatsby .cache and public folder to speed up your build time by 10x
JavaScript
Branch: master
Clone or download
Pull request Compare This branch is 2 commits ahead of axe312ger:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
test
.eslintrc.js
.gitignore
.npmignore
.prettierrc
README.md
index.js
package.json

README.md

gatsby-plugin-netlify-cache

NPM   NPM downloads

This plugin caches your build files locally or in the Netlify cache directory. It will massively speed up subsequent builds.

☁️ Installation

npm install gatsby-plugin-netlify-cache

🛫 Setup

Add 'gatsby-plugin-netlify-cache' to the plugins in your gatsby-config.js file.

 Usage

Locally

In your local environment nothing happens to avoid conflicts with your development process. It actually checks if process.env.NETLIFY_BUILD_BASE exists to detect a Netlify environment.

Netlify

It automatically restores your cache and caches new files within the Netlify cache folder. This folder is undocumented but works fine. To reset the cache, hit the Clear build cache checkbox in the Netlify app.

These folders are cached by default:

  • .cache directory
  • public directory

⚙️ Configuration

cachePublic - default: false

Caching the public directory on long term can result in a huge directory size which can break your netlify build. Enable this with caution.

plugins: [
  {
    resolve: "gatsby-plugin-netlify-cache",
    options: {
      cachePublic: true
    }
  }
]

extraDirsToCache - default: []

If you need additionals directories to be cached, you can use the option extraDirsToCache to include one or multiple directories to Netlify cache:

plugins: [
  {
    resolve: "gatsby-plugin-netlify-cache",
    options: {
      extraDirsToCache: [
        "extraDir",
        ".extraDotDir",
        "extra/dir"
      ]
    }
  }
]

Note: the directory path is relative to the project root directory

You can’t perform that action at this time.