gatsby-source-s3
gatsby-source-s3 copied to clipboard
feat: caching
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
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.
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 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?
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!