From 0b32c3a21cb866a8c13a47a47d6975287d98f094 Mon Sep 17 00:00:00 2001
From: Jace Bennest <jacebennest87@gmail.com>
Date: Tue, 27 Aug 2019 06:10:44 +0000
Subject: [PATCH] [#2838] add cache override explanation

---
 doc/ci/caching/index.md | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/doc/ci/caching/index.md b/doc/ci/caching/index.md
index f8151e3e18c41..a59a0477b8011 100644
--- a/doc/ci/caching/index.md
+++ b/doc/ci/caching/index.md
@@ -172,6 +172,29 @@ job:
   cache: {}
 ```
 
+### Inherit global config, but override specific settings per job
+
+You can override cache settings without overwriting the global cache by using
+[anchors](../yaml/README.md#anchors). For example, if you want to override the 
+`policy` for one job:
+
+```yaml
+cache: &global_cache
+    key: ${CI_COMMIT_REF_SLUG}
+    paths:
+      - node_modules/
+      - public/
+      - vendor/
+    policy: pull-push
+
+job:
+  cache:
+    # inherit all global cache settings
+    <<: *global_cache
+    # override the policy
+    policy: pull
+```
+
 For more fine tuning, read also about the
 [`cache: policy`](../yaml/README.md#cachepolicy).
 
-- 
GitLab