# Cache invalidation in CircleCI

**URL:** <https://discuss.circleci.com/t/cache-invalidation-in-circleci/53828>\
**Category:** Caching Dependencies\
**Created:** [July 30, 2025, 8:21am UTC](https://discuss.circleci.com/t/cache-invalidation-in-circleci/53828 "2025-07-30T08:21:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![OPeyrusse](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/opeyrusse/32/25382_2.png) [@OPeyrusse](https://discuss.circleci.com/u/OPeyrusse)\
**Post date:** [July 30, 2025, 8:21am UTC](https://discuss.circleci.com/t/cache-invalidation-in-circleci/53828/1 "2025-07-30T08:21:24Z")

</div>

The documentation explains how it is possible to restore cache from partial key matching, which can help obtaining an older version of the cache, not perfectly fitted but better than downloading everything.

> **[Configuration reference - CircleCI](https://circleci.com/docs/configuration-reference/#restorecache)**
>
> Reference for .circleci/config.yml

And, for an organization, there is a unique setting controlling the cache lifetime (set in days)

My question is: are all caches invalidated at once, or does it happen per cache, based on their individual ages?

The answer will help me find the best approach to cache management in the following case:  
Consider a project with the following restore config

```yaml
restore_cache:
  keys:
    - v1-myapp-{{ arch }}-{{ checksum "project.clj" }}
    - v1-myapp-{{ arch }}-
    - v1-myapp-

```

And consider the following timeline, with a 7-day cache lifetime

1. Day 1: create `v1-myapp-linux-abc`
2. Day 3: create `v1-myapp-macos-cde`
3. Day 5: create `v1-myapp-linux-xyz`

On day 8, cache `v1-myapp-linux-abc` becomes invalid and must be rebuild. If `v1-myapp-macos-cde` or `v1-myapp-linux-xyz` still exist, we will rebuild the cache from them and add some missing deps, growing the cache.  
Then, on day 10, `v1-myapp-macos-cde` becomes invalid and is rebuilt from either `v1-myapp-linux-xyz` or `v1-myapp-linux-abc`, with even more deps  
There would be a snowball effect where caches keep growing.

Because our system has hundreds of concurrent builds, it is hard for me to track down the right job that create the cache after invalidation (and even figure which one sees first an invalid cache), hence my general question here.

I don’t mind if the answer is that this snowball effect is a thing. It would simply be another thing to consider when creating caches.  
But not knowing is the worst 😉

Cheers
