gatsby-source-s3 icon indicating copy to clipboard operation
gatsby-source-s3 copied to clipboard

feat: caching

Open robinmetral opened this issue 5 years ago • 4 comments

This is already handled by Gatsby pretty well, but the Cache API can be leveraged to make sure the pulled images are persisted between builds.


Relevant Gatsby PRs about caching for plugins:

  • https://github.com/gatsbyjs/gatsby/issues/11785
  • https://github.com/gatsbyjs/gatsby/pull/8379
  • https://github.com/gatsbyjs/gatsby/pull/22090

Relevant docs:

  • https://www.gatsbyjs.org/docs/creating-a-source-plugin/#caching-data-between-runs

robinmetral avatar Mar 20 '20 20:03 robinmetral

This would really be lovely - potentially a huge time-saver.

Cache API by itself very easy to use:

let obj = await cache.get(cacheKey) ... await cache.set(cacheKey, obj)

Though I am not sure how complex will it be to use it for each and every fetched image.

Vacilando avatar Nov 17 '21 21:11 Vacilando

That sounds great @Vacilando! I've been pushing this back because I never really used the Gatsby cache explicitly 😅—do you want to open a PR for it?

robinmetral avatar Nov 18 '21 00:11 robinmetral

@robinmetral I've looked into caching imageFile in onCreateNode() - then realized that if the Gatsby flag PRESERVE_FILE_DOWNLOAD_CACHE the image files are already being used from cache (thanks to the use of plugin gatsby-source-filesystem).

Where else do you see we could use caching to improve the cache efficiency?

Vacilando avatar Dec 03 '21 22:12 Vacilando

Thanks for your interest in this project. This plugin is moving into the Gatsby User Collective and this repo will be archived. Please open an issue in that repository, submit a PR if you'd like to see this implemented, or Join us on Discord if you have questions!

moonmeister avatar Jan 31 '22 17:01 moonmeister