GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Caching fallback if there is no exact hit · Issue #328 · actions/setup-node

Caching fallback if there is no exact hit #328

New issue
Copy link
New issue
Copy link
Open
#702
Open
Caching fallback if there is no exact hit#328
#702
Copy link
Labels
feature requestNew feature or request to improve the current logic

Description

@dbartholomae
dbartholomae
opened on Sep 5, 2021
Issue body actions

Hi there,

at the moment, caching only hits if the exact same lockfile exists, but most of the time, even it the lockfile slightly changes, it is still beneficial to restore cache instead of downloading everything from scratch (most likely only ~1 dependency changed).
I would propose that, by default, cache falls back to node-cache-${platform}-${packageManager} instead of only checking node-cache-${platform}-${packageManager}-${fileHash}.
If this is of interest, I'm happy to provide a PR. It seems to only need a test and a one line change in https://github.com/actions/setup-node/blob/main/src/cache-restore.ts#L44

See also #304 (comment)

Reacted by Connor Grady, Ali, Jonathan del Strother, Nick Graef, lharress, Alexander Malitsky, Dustin Martin, Reinier Timmer, Minoru Takeuchi, Gabriel Cangussu and 26 more

Activity

  1. dmitry-shibanov
    added
    feature requestNew feature or request to improve the current logic
    on Oct 21, 2021
  2. nigelzor
    added a commit that references this issue on Dec 8, 2021

    provide fallback cache keys

    bd6483a
  3. oxc commented on Feb 1, 2022

    @oxc
    oxc
    on Feb 1, 2022
    More actions

    There seem to be implementations for this in #323 and thrivehealth@bd6483a

  4. marko-zivic-93
    assigned
    e-korolevskii
    on Apr 29, 2022
  5. marko-zivic-93
    unassigned
    e-korolevskii
    on Jun 10, 2022
  6. IvanZosimov
    self-assigned this
    on Sep 6, 2022
  7. belgattitude commented on Oct 10, 2022

    @belgattitude
    belgattitude
    on Oct 10, 2022
    More actions

    Just for sharing some workarounds with @action/cache

    • With Pnpm 7+: https://gist.github.com/belgattitude/838b2eba30c324f1f0033a797bab2e31
    • With Yarn 3+: https://gist.github.com/belgattitude/042f9caf10d029badbde6cf9d43e400a
    Reacted by Bernhard Frauendienst
  8. IvanZosimov
    removed their assignment
    on Oct 18, 2022
  9. voxpelli commented on Feb 27, 2023

    @voxpelli
    voxpelli
    on Feb 27, 2023
    More actions

    New PR to fix this: #702

  10. nigelzor
    added a commit that references this issue on Feb 28, 2023

    provide fallback cache keys

    3ec743e
  11. dusan-trickovic
    added
    needs eyes
    on Jul 12, 2023
  12. dusan-trickovic
    removed
    needs eyes
    on Aug 3, 2023
  13. deining
    added a commit that references this issue on Nov 9, 2023

    chore(deps-dev): bump prettier from 2.4.1 to 2.5.0 (actions#328)

    f6438de
  14. voxpelli commented on Mar 13, 2024

    @voxpelli
    voxpelli
    on Mar 13, 2024
    More actions

    Rebased and updated the PR over at #702, needed adaption after #744 was merged

  15. v-aparnajyothi-y commented on Sep 30, 2025

    @v-aparnajyothi-y
    v-aparnajyothi-y
    on Sep 30, 2025
    Contributor
    More actions

    Hello Everyone, Thank you for raising this request and for the thoughtful PR. We completely understand the motivation behind introducing a fallback caching mechanism, as it could help improve efficiency in certain scenarios.

    That said, after discussion, we’ve decided not to move forward with this change. The main concern is that fallback caching may lead to unpredictable behavior like restoring stale dependencies, introducing subtle inconsistencies, and making workflows harder to debug. Ensuring reproducibility and determinism is a core design principle for setup-node, and strict cache key matching helps guarantee that.

    For teams that prefer more flexible caching strategies, we recommend using actions/cache directly, where you can design custom keys and fallbacks as needed.

    We really appreciate your contribution and the effort put into this proposal. Even though we can’t merge this change, we encourage you to continue sharing ideas and feedback with us, as it helps shape the future improvements.

  16. nwalters512 commented on Sep 30, 2025

    @nwalters512
    nwalters512
    on Sep 30, 2025
    More actions

    Can you say more about the specific "subtle inconsistencies" and "stale dependencies" you're worried about? At least with Yarn, my understanding is that it'll only pull things from the disk cache if they're an exact match with the lockfile and if the checksum is correct (see checksumBehavior on https://yarnpkg.com/configuration/yarnrc).

    I think it also makes intuitive sense that package managers will function correctly with a cache that doesn't contain exactly what it needs. Consider the case where I clone a random project to my machine and run yarn install or similar: a package manager will use the cache if it can, but it'll still happily pull anything that's missing from the cache from the npm registry.

    I'd appreciate links to specific GitHub issues or sections of package manager documentation that explains how they could possibly end up constructing an incorrect dependency tree if the cache is "outdated".

    I should also add that using a fallback restore key matches GitHub's own best practices as documented in actions/cache: https://github.com/actions/cache/blob/main/examples.md#node---yarn

    Reacted by Dave Johansen and Schambach
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestNew feature or request to improve the current logic

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.