-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
feat(gatsby): Add new caching clearing behavior for webpack/file downloads behind flags #28334
Conversation
7403aa1
to
a1df5c4
Compare
Hmmm is this even a breaking change? Why not just release this now? Not behind a flag? I think I started with this being a flag in mind as I also want to change the behavior of |
Technically this can end up with issues. Unsure if cache keys of webpack & babel are correct. If we change |
… to updated versions of source-filesystem
Some updates from a conversation between @pieh, @wardpeet, and me earlier
|
// Attempt to empty dir if remove fails, | ||
// like when directory is mount point | ||
await fs.remove(cacheDirectory).catch(() => fs.emptyDir(cacheDirectory)) | ||
// Comment out inviet until we can test perf impact |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Comment out inviet until we can test perf impact | |
// Comment out invite until we can test perf impact |
;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How
…loads behind flags (#28334) * feat(gatsby): Add new caching behavior for v3 behind a flag * change to CACHE_CLEAR * cleanup * Split into two flags * Update invite wording + do semver check so we don't keep showing this to updated versions of source-filesystem * Add invite for webpack flag * First try grabbing the plugin from and if that fails, try requiring * Don't use del or readdir until measure perf more * Remove now unused imports * Nest ifs (cherry picked from commit f57d590)
…loads behind flags (#28334) (#28425) * feat(gatsby): Add new caching behavior for v3 behind a flag * change to CACHE_CLEAR * cleanup * Split into two flags * Update invite wording + do semver check so we don't keep showing this to updated versions of source-filesystem * Add invite for webpack flag * First try grabbing the plugin from and if that fails, try requiring * Don't use del or readdir until measure perf more * Remove now unused imports * Nest ifs (cherry picked from commit f57d590) Co-authored-by: Kyle Mathews <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like this
We're investigating ways to be smarter about clearing caches.
Currently we delete the entire cache when your gatsby-node.js, gatsby-config.js, or package versions change or you run gatsby clean. This is unnecessarily aggressive — changing these things don't invalidate most caches. The current cache clearing behavior means very expensive operations like downloading and processing images have to be repeated quite often which makes iterating on the website a lot more frustrating than it should.
This PR adds two new flags:
PRESERVE_FILE_DOWNLOAD_CACHE
prevents file downloads from being deleted during cache clearing events (other thangatsby clean
which still deletes the entire cache).PRESERVE_WEBPACK_CACHE
prevents the webpack cache from deleted with the same caveat forgatsby clean
We will continue to clear other plugin caches e.g. those created by source & transformer plugins. We're looking at ways to safely making more selective clearing those caches as well.
To enable the new cache behavior, add to your gatsby-config.js:
These will also be enabled if you add the
FAST_DEV
flag which enables a number of WIP ways to speed up the dev server.