How can I clear a CircleCI cache?

Overview

Caches are immutable and cannot be cleared. In some cases such as when you've updated language or build management tool versions, you may need a fresh cache.

 

Resolution: 

In place of deleting your cache, you can generate a new cache by updating the cache key. 

To make this as easy and maintainable as possible, we recommend the following format for cache keys:

v1-node-{{ checksum "package.json" }}

With this, you can simply increment v1 to v2  in order to start a fresh cache.

Updating the cache key on save and restore steps in your .circleci/config.yml file will generate new sets of caches from that point onwards

 

If you create a new cache by incrementing the cache version, the “older” cache is still stored. It is important to be aware that you are creating an additional cache and this method will increase your storage usage. As a general best practice, you should review what is currently being cached and reduce your storage usage as much as possible.

You can modify your data retention policies, and associated storage costs, through custom storage usage.

 

Additional Resources: 

Was this article helpful?
1 out of 33 found this helpful

Comments

0 comments

Please sign in to leave a comment.