# Notes on caching Docker layers in CircleCI

**URL:** <https://discuss.circleci.com/t/notes-on-caching-docker-layers-in-circleci/22067>\
**Category:** Tips, Tricks, and Hacks\
**Tags:** cache, docker\
**Created:** [April 29, 2018, 8:26pm UTC](https://discuss.circleci.com/t/notes-on-caching-docker-layers-in-circleci/22067 "2018-04-29T20:26:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![halfer](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/halfer/32/9083_2.png) [@halfer](https://discuss.circleci.com/u/halfer)\
**Post date:** [April 29, 2018, 8:26pm UTC](https://discuss.circleci.com/t/notes-on-caching-docker-layers-in-circleci/22067/1 "2018-04-29T20:26:18Z")

</div>

I’ve been playing with Docker layer caching on the free tier, and have [written up some strategies](https://blog.jondh.me.uk/2018/04/strategies-for-docker-layer-caching-in-circleci/) I tried. There is an out-of-the-box cache device in CircleCI available to paid users, for an extra fee, but with a bit of extra work, anyone can have access to faster builds. My article is fairly discursive, since the kind of caching that is preferred will vary from one project/team to another.

Long story short, it is my opinion that using an external registry was more effective than using the CircleCI caching device, since the cache is always kept up-to-date.

I am inclined to make some tweaks to my current config. In particular, it would be good to scan the registry to check the age of the latest image, and if it is more than (say) five days old, force the build to not use the cache. That will probably be the subject of another post…

---

<div class="post-metadata">

**Author:** ![levlaz](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/levlaz/32/36978_2.png) [@levlaz](https://discuss.circleci.com/u/levlaz)\
**Post date:** [April 29, 2018, 8:29pm UTC](https://discuss.circleci.com/t/notes-on-caching-docker-layers-in-circleci/22067/2 "2018-04-29T20:29:52Z")

</div>

Very nice, thanks for sharing!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/circleci/original/3X/5/1/511608acda8e85906e15909b57bd0a46c1dbe291.png) [@system](https://discuss.circleci.com/u/system)\
**Post date:** [July 28, 2018, 8:29pm UTC](https://discuss.circleci.com/t/notes-on-caching-docker-layers-in-circleci/22067/3 "2018-07-28T20:29:55Z")

</div>

Closed on July 28, 2018, 8:29pm UTC

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
