Skip to content

Add Custom Cache plugin (netlify-plugin-cache) #83

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jakejarvis
Copy link

Are you adding a plugin or updating one?

  • Adding a plugin
  • Updating a plugin

Have you completed the following?

Test plan

My own Hugo site (see its netlify.toml here) uses this plugin to cache the resources 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 of cache-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! 😊

@jakejarvis jakejarvis force-pushed the add-netlify-plugin-cache branch from f42ffb7 to 3504e40 Compare June 6, 2020 20:17
@ehmicky ehmicky self-requested a review June 8, 2020 19:01
@ehmicky ehmicky added feat/build-plugins type: feature code contributing to the implementation of a feature and/or user facing functionality labels Jun 8, 2020
@ehmicky
Copy link
Contributor

ehmicky commented Jun 8, 2020

This is truly awesome!
I have added two minor comments as issues in the repository. Apart from this, this looks good to me!

Thanks a lot @jakejarvis, I predict this will become a highly used plugin :)

@slorber
Copy link

slorber commented Jun 16, 2020

Wanted this plugin.
jlengstorf/netlify-plugin-gatsby-cache#20

Just tried it, and worked great for me to add an additional folder to regular gatsby caching :)

[[plugins]]
package = "netlify-plugin-cache"
  [plugins.inputs]
  paths = [".cache", "public", "imagesProd"]

thanks

@jakejarvis
Copy link
Author

Thanks so much for taking the time @ehmicky and apologies for the late response! Will bump the version number here once those are all taken care of (namely jakejarvis/netlify-plugin-cache#3 if you or anyone else has ideas).

@ehmicky
Copy link
Contributor

ehmicky commented Jun 16, 2020

Just answered it. Thanks @jakejarvis!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feat/build-plugins type: feature code contributing to the implementation of a feature and/or user facing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants