WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit dda4788

Browse files
Add example for restore-only cache in documentation (#1419)
* Update versions.yml * Update versions.yml * doc update * update * update * doc update
1 parent 2028fbc commit dda4788

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

docs/advanced-usage.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,35 @@ steps:
300300
- run: npm test
301301
```
302302

303+
**Restore-Only Cache**
304+
305+
```yaml
306+
## In some workflows, you may want to restore a cache without saving it. This can help reduce cache writes and storage usage in workflows that only need to read from cache
307+
jobs:
308+
build:
309+
runs-on: ubuntu-latest
310+
steps:
311+
- uses: actions/checkout@v5
312+
# Restore Node.js modules cache (restore-only)
313+
- name: Restore Node modules cache
314+
uses: actions/cache@v4
315+
id: cache-node-modules
316+
with:
317+
path: ~/.npm
318+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
319+
restore-keys: |
320+
${{ runner.os }}-node-
321+
# Setup Node.js
322+
- name: Setup Node.js
323+
uses: actions/setup-node@v6
324+
with:
325+
node-version: '24'
326+
# Install dependencies
327+
- run: npm install
328+
```
329+
330+
> For more details related to cache scenarios, please refer [Node – npm](https://github.com/actions/cache/blob/main/examples.md#node---npm).
331+
303332
## Multiple Operating Systems and Architectures
304333

305334
```yaml

0 commit comments

Comments
 (0)