Add Custom Cache plugin (netlify-plugin-cache) #83
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Are you adding a plugin or updating one?
Have you completed the following?
Test plan
My own Hugo site (see its
netlify.toml
here) uses this plugin to cache theresources
folder (with images processed/resized by Hugo, sometimes painfully slowly) and_vendor
(cached Go modules). Successful deploy log here:https://app.netlify.com/sites/jakejarvis/deploys/5edbba4109b2da00072a9f18
The plugin's readme suggests different settings for various SSGs. This is also linked to in the plugin output if the
paths
input refers to directories/files that don't exist — see the logs for a "failure" here (note the actual deploy doesn't fail):https://app.netlify.com/sites/jakejarvis/deploys/5edbadf4787452f2795751b0
More info
Repo: https://github.com/jakejarvis/netlify-plugin-cache
NPM: https://www.npmjs.com/package/netlify-plugin-cache
I see a few great cache plugins already made for Hugo, Gatsby, Next.js, etc. but not a plugin that simply accepts an open-ended input allowing a user to cache whatever files/folders they want. This plugin does just that — basically a pretty wrapper around the native
cache
util.The plugin defaults to caching
[".cache"]
but can accept an array of any file(s) and/or folder(s) via the one input variable,paths
. The readme instructs users to use the official netlify-plugin-debug-cache plugin to list the contents of the cache for debugging/verification (no need to re-invent the wheel!), I've uploaded an example ofcache-output.json
here (after running this plugin).I'm completely open to comments/suggestions if this isn't ready for the directory, or feel free to close if you think it's too generic to be listed.
Thanks! 😊