Home
Support Forums

How can I force netlify to not cache certain things?

In my build script I do a git clone on a second repo, but the second repo is getting cached. It will only update if I manually go into netlify and click “clear cache and deploy site”. The auto-deploys always use a cached version, which I do not want.

Can I disabled it for a certain url, or clear it with my build script or something?

Hi, @skeddles. If the cached content is not your publish directory and doesn’t include it as subdirectory, you can append something like && rm -Rf path/to/directory/to/delete to your build command.

Please note, that && is important. If you add it using ; and not && it will hide build failures (it “swallows” the exit code error) and that will cause failed builds to be published.

Clearly, publishing failed builds is not something we want to do.

For example, if the build command is npm run build and the path you do not want to cache is ./themes/theme-name then then you can keep the build image from caching that directory with:

npm run build && rm -Rf ./themes/theme-name

If that doesn’t work or if there are other questions, please let us know.