Creating a "daily" cache

Daily Cache

Note: This is not required or recommended for many use cases, but can prove potentially useful for some instances.

For example, if you are building static blog sites that fetch from external API's, you may want to build with a new cache periodically to ensure any new information is fetched.


Early in your job, create a file containing today's date without a timestamp:

- run: date +%F > date

You can now use this file to test against when choosing when to rebuild cache by utilizing the checksum template.

      - restore_cache:
            - date-cache-{{ checksum "date" }}
      - save_cache:
            key: date-cache-{{ checksum "date" }}
                - "/docs"

The checksum of the date file will remain static until the next day, at which point a new cache will be created.

Note: The old caches will still exist under a different cache key and will expire after 15 days as per our retention policy:


Was this article helpful?
18 out of 19 found this helpful



Article is closed for comments.