Skip to content
View entire changelog

Job-level cache retention controls

Enhancement

Users can now set cache retention periods at the job level using the retention key in CircleCI config. Job level retention overrides the retention period set in plan usage controls, allowing users to optimize cache storage for their individual jobs. Flexible cache retention periods are useful for workflows with varying cache needs, such as short-lived feature branch jobs or jobs with frequently changing dependencies.

Set cache retention at the job level

jobs:
 hello-world:
   machine:
    image: ubuntu-2404:current
   steps:
    - run:
      name: Hello World
      command: echo "hello-world"
   retention:
    caches: 5d  # Keep caches for 5 days instead of default

Job-level settings can only reduce retention - not extend beyond plan limits. If retention is not set at the job level, caches will be stored for the period set in plan usage controls.

Learn more about CircleCI retention settings in our documentation.