Gatsby contains its own internal cache that is used to accelerate plugin handling, and especially the data sourcing process. Sometimes the Gatsby cache can fail, manifesting in strange and perhaps silent errors involving stale content, where the most up-to-date content doesn’t display despite an upstream content update, and recent modifications to plugin code that don’t appear to execute.
Gatsby uses a .cache directory to cache certain elements of the Gatsby site. Starting with Gatsby v2.1.1, the gatsby clean
command is available to clear out the Gatsby cache and ensure the most recent versions of your plugin code and content are represented in your site:
$
gatsby
clean
Prior to v2.1.1, an NPM script was required in the site’s package.json file, as follows:
//
package.json
{
"scripts"
:
{
"clean"
:
"rm -rf .cache"
}
}
To run this NPM script for v2.1.0 and earlier, execute:
$
npm
run
clean
Leave a Reply