# Dynamic or programmatic caching of directories?

**URL:** <https://discuss.circleci.com/t/dynamic-or-programmatic-caching-of-directories/1455>\
**Category:** Build Environment\
**Tags:** caching, circle-yml\
**Created:** [January 11, 2016, 4:32pm UTC](https://discuss.circleci.com/t/dynamic-or-programmatic-caching-of-directories/1455 "2016-01-11T16:32:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![suan](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/suan/32/1006_2.png) [@suan](https://discuss.circleci.com/u/suan)\
**Post date:** [January 11, 2016, 4:32pm UTC](https://discuss.circleci.com/t/dynamic-or-programmatic-caching-of-directories/1455/1 "2016-01-11T16:32:02Z")

</div>

Our situation is that we have a main Rails app, but which has many child components, some of which are client-side apps, etc. We need to cache directories like node\_modules/ for some components, but we don’t want to explicitly list each needed cache path for each component, as that introduces a pretty tight coupling between the main app and its components.

Does the circle.yml configration provide a way to read a list of cache\_directories paths from a single file, or recognize glob paths, or a way to programatically/dynamically cache directories?

---

<div class="post-metadata">

**Author:** ![alexey](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/alexey/32/42_2.png) [@alexey](https://discuss.circleci.com/u/alexey)\
**Post date:** [January 13, 2016, 9:47am UTC](https://discuss.circleci.com/t/dynamic-or-programmatic-caching-of-directories/1455/2 "2016-01-13T09:47:26Z")

</div>

Unfortunately globs are not supported in `cache_directories`, nor is it possible to read the list of directories from a file.

What you could do, though, is move the directories you want to cache to a specific subdirectory in the home folder and then symlink those directories into where they should be available. This way you could cache the whole directory at once but still have flexibility as per which directories are cached and where are they made available in your app folder.

---

<div class="post-metadata">

**Author:** ![SpainTrain](https://sea2.discourse-cdn.com/circleci/user_avatar/discuss.circleci.com/spaintrain/32/152_2.png) [@SpainTrain](https://discuss.circleci.com/u/SpainTrain)\
**Post date:** [January 18, 2018, 10:30pm UTC](https://discuss.circleci.com/t/dynamic-or-programmatic-caching-of-directories/1455/3 "2018-01-18T22:30:08Z")

</div>

Is this feature being considered for your roadmap? This unfortunately kills the ability to do proper caching for monorepos (without burdensome config churn), which are becoming more popular in the node community thanks to the lerna tool and popular projects using the pattern (e.g., babel).

---

<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:** [June 18, 2018, 11:37am UTC](https://discuss.circleci.com/t/dynamic-or-programmatic-caching-of-directories/1455/4 "2018-06-18T11:37:54Z")

</div>


