Enable caching on failing builds


we are trying to migrate out GatsbyJs build to netlify. When building on GatsbyJs the initial build fails and the rebuild with cache works. The problem we are facing ist that there seems to me no caching on netlify when the build fails. Is there a way to enable caching even when the build fails?

Best Regards

Hi @michaela,

Are you still seeing this issue? If you could let us know the site name (example sitename.netlify.app) or send a link to the failed build we can investigate the build failure with you.


the site name is internationalestiftung.netlify.app. Thank you for your help.

Best Regards

Yes, Netlify doesn’t cache failed builds and we don’t intend to. A build might have failed due to various reasons and saving a filed build’s cache could basically lead to more troubles and debugging than not saving the cache. If there’s a strong argument to add support for caching failed builds other than build time, let us know and we can file it as a feature request.

Hi @hrishikesh, time might be one thing the other is either Wordpress as a datasource or some other issue.
In gatsbyjs.com we have manual builds that take about 1 hour and 17 minutes and fail either due to gatsby-source-wordpress (WPGraphQL schema) or probably while building the static html.
When rebuilding (manual) with cache of the failed build, the build succeeds in 3 minutes and is correctly deployed.
This behaviour is reproducable.

So I am not sure if this is a strong argument, but without caching the migration from gatsby.js to netlify will probably involve more changes e.g. updating gatsby4 to lastest and making sure everything still works/ and hoping that gatsby5 would solve the issue with caching.

After discussing the issue with the support we found out that it is related to out of memory issues, which we did not really get from the issues displayed by the build.

One suggestion was to try the environment variable GATSBY_CPU_COUNT with the value 1 or 2.
With the value “2” the build was successful.

Thank you for your support :slight_smile:

Hi, glad you found a solution. Thanks for coming back and sharing this with the community!