Azure Pipelines added a caching capability a while back and I thought it was high time I enable it.

I was updating a project I maintain and using the example from the docs, I was able to add [caching to my build] (

In the short term, I’ve noticed about 2 minutes per job saved by restoring the cache. (It is Ruby on Windows, so the impact may be a bit outsized to your language of choice.)

How does it work?

The caching targets a particular file path and uses a key you specify. The key can be a combination of files or strings that identify the current state of dependencies. In my build, I use the operating system, ruby version, and gemspec file.

Things to be aware of

  • Caches expire after 7 days of inactivity. If you have a rarely built project, this may be of minimal benefit.
  • If you want to break your cache, you can just tweak the key value (either add or change something) and it’ll invalidate the old cache.

Give it a try in your build and see how it works! (Read more here)