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 — Add option to restore cache only · Issue #316 · actions/setup-go

Add option to restore cache only #316

New issue
Copy link
New issue
Copy link
Open
#400
Open
Add option to restore cache only#316
#400
Copy link
Labels
feature requestNew feature or request to improve the current logic

Description

@ForsakenHarmony
ForsakenHarmony
opened on Jan 10, 2023
Issue body actions

Description:
It would be nice to have the option to restore only and not save.

Justification:
In bigger repos, it's easy to hit the 10gb cache limit. Not caching in PRs can help with this.
Right now, I have to manually delete caches to help keep the caches on main alive.

Are you willing to submit a PR?

References

actions/toolkit#1308
Swatinem/rust-cache#95 (has a save-if option https://github.com/Swatinem/rust-cache#example-usage)

Reacted by Greg Weber, Mitch Fierro, Enrico Minack, TheoAlloin, Alex Crawford, Otto Richter (fnetX), Bryce Lampe, Brian Conway, Nelz, Teppei Fukuda and 23 more

Activity

Next
  1. ForsakenHarmony
    added
    feature requestNew feature or request to improve the current logic
    needs triage
    on Jan 10, 2023
  2. e-korolevskii commented on Jan 11, 2023

    @e-korolevskii
    e-korolevskii
    on Jan 11, 2023
    Contributor
    More actions

    Hello @ForsakenHarmony! Thank you for the suggested idea!
    We will consider adding this feature and will let you know as soon as we have any decision.

  3. e-korolevskii
    removed
    needs triage
    on Jan 11, 2023
  4. gwatts commented on Jan 19, 2023

    @gwatts
    gwatts
    on Jan 19, 2023
    More actions

    @ForsakenHarmony likely seen this already, but if not you might find this helpful too to automatically delete PR caches when the PR is closed: https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#force-deleting-cache-entries

  5. ForsakenHarmony commented on Feb 1, 2023

    @ForsakenHarmony
    ForsakenHarmony
    on Feb 1, 2023
    Author
    More actions

    @gwatts yes, I'm doing that, doing it after each commit's CI is done actually, but it's an ugly workaround

    Reacted by Gareth Watts
  6. dsame
    self-assigned this
    on Mar 31, 2023
  7. dsame commented on Apr 5, 2023

    @dsame
    dsame
    on Apr 5, 2023
    Contributor
    More actions

    Hello @ForsakenHarmony, if i understood your request correctly you need the "restore cache only" action https://github.com/actions/cache/blob/main/restore/README.md

    Does it solve the problem?

    Reacted by Donald Silveira
    Reacted by hrmny, Enrico Minack, Otto Richter (fnetX) and Brian Conway
  8. lzap commented on May 17, 2023

    @lzap
    lzap
    on May 17, 2023
    More actions

    We would love this feature too. Our CI pipeline consist of:

    • build job (runs go build)
    • test job (runs go test)

    When cache is enabled (default in v4) and there is a change in go.sum both jobs run in parallel but because our build job is slower, test job wins and uploads the cache. Problem is, the test job does not build all code path - only those which are executed by unit tests. The next time cache is downloaded, build job will use the cache created by test job which is not 100% so this is leading to wasted CPU cycles.

    We would like to configure test job to "download only", basically ability to disable the setup-go post hook uploading the cache.

    Reacted by Mark Nevill
  9. lzap commented on May 17, 2023

    @lzap
    lzap
    on May 17, 2023
    More actions

    How do I use lookup-only with setup-go?

  10. dsame commented on Jul 10, 2023

    @dsame
    dsame
    on Jul 10, 2023
    Contributor
    More actions

    Hello @lzap,
    you need to disable go caching and use https://github.com/actions/cache/blob/main/restore/README.md

    Reacted by Mark Nevill
    Reacted by Lukáš Zapletal
  11. lzap commented on Jul 11, 2023

    @lzap
    lzap
    on Jul 11, 2023
    More actions

    Unfortunately, I am having hard time figuring out how setup-go creates the cache key. The SHA sums for my case do not match for some reason: setup-go-Linux-go-1.19.6-2ecd730a3adf2d5167ee1676ce4793359350a5aef4bc40807996837393159830

    It does not match:

    $ sha256sum go.sum go.mod
    8aeed24d8b1117586e0d269bbe1861de7bfcde3cbdf78e8dea77c6e0bea565cf  go.sum
    f1da5013a602ea3becd1c57d497592f7cdce5390d7ddc0ebab0d7b0b8475e33f  go.mod
    

    Are you saying that I need to completely disable go caching and write caching myself (both store and retrieve)? That is exactly what I don’t want to do and the primary reason why I 👍🏻 on this issue.

    Frankly either a key prefix/suffix or some sort of "lookup-only" flag that would be passed into the cache action would be really cool. I don’t know TS/JS so crossing my fingers this gets picked up sometime. Not a big deal for our project right now, we disabled caching for some actions for now.

  12. dsame commented on Jul 12, 2023

    @dsame
    dsame
    on Jul 12, 2023
    Contributor
    More actions

    hello @lzap

    This issue requests new feature "Add option to restore cache only". It won't be implemented because it duplicates the functionality of the existing action: https://github.com/actions/cache/blob/main/restore/README.md

    You should disable basic caching for setup-go https://github.com/actions/setup-go#caching-dependency-files-and-build-outputs

    and add a step with restore only action https://github.com/actions/cache/blob/main/restore/README.md

    As a result the workflow should contain something like this:

      - uses: actions/setup-go@v4
        with:
          go-version: '1.17'
          cache: false
        
      - uses: actions/cache/restore@v3
        id: cache
        with:
          path: path/to/dependencies
          key: ${{ runner.os }}-${{ hashFiles('go.sum go.mod') }}
    

    does it help?

    Reacted by Mark Nevill, Bryce Lampe and pura-tainguyen
  13. lzap commented on Jul 12, 2023

    @lzap
    lzap
    on Jul 12, 2023
    More actions

    Hey thanks for comment, I understand, however, let me argue that the behavior is not documented at the moment. I had hard time figuring out how hash is actually calculated, I had no idea that both files are concatenated and in this order. Maybe this issue could be turned into documentation change.

    Still I think this could be useful feature for couple of reasons. A single option is much easier to write than additional 5 lines long extra action. It is not just that, please realize that we need this functionality when we have multiple parallel actions which "fight" each other for the initial cache save, so it is not just 5 lines, but 20 lines of copy-pasted YAML for my case (4 actions - build, unit tests, integration tests and linter).

    It does not have to be restore cache attribute, this could be easily implemented as cache prefix/suffix attribute which would allow us to create separate caches for various actions which interfere witch each other.

    Finally, when setup-go action authors decide to change the key pattern, it will break others pipelines and it will be pain to figure it out. A consistency is my last argument. And with that, I will, again, thank you for your comment and effort you put into this project. I will try to implement what you suggested now.

  14. lzap commented on Jul 12, 2023

    @lzap
    lzap
    on Jul 12, 2023
    More actions

    Oh I just learned that it is not just 5 lines, what you pasted is not functional example. I need to figure out path to dependencies that is another action. Also the key does not match what I see. I guess I will keep cache disabled for tests in our case :-(

  15. 16 remaining items

  16. v-aparnajyothi-y commented on Dec 17, 2025

    @v-aparnajyothi-y
    v-aparnajyothi-y
    on Dec 17, 2025
    Contributor
    More actions

    Hello Everyone, Thanks everyone for your patience and contributions. This issue reported here has been addressed in #696. The documentation helps cache state restoration handling.
    Please feel free to reach us in case of any further clarifications/concerns :)

  17. gavinsharp commented on Dec 17, 2025

    @gavinsharp
    gavinsharp
    on Dec 17, 2025
    More actions

    @aparnajyothi-y documentation for how to implement custom caching yourself is not really addressing this request, which is an easy-to-use feature to achieve the same result without custom caching logic (which needs to be maintained as toolchains evolve)

  18. v-aparnajyothi-y commented on Dec 23, 2025

    @v-aparnajyothi-y
    v-aparnajyothi-y
    on Dec 23, 2025
    Contributor
    More actions

    Hello @gavinsharp, thanks for following up and really appreciate the clear explanation.

    You’re right that documenting custom caching doesn’t fully address the request for a simple, built-in restore-only feature. The intent of #696 was to provide guidance for what’s possible today, while keeping setup actions opinionated to ensure predictable and safe caching without requiring manual key management.

    For teams with advanced or highly customized caching needs, actions/cache remains the recommended approach, as it provides full control for more complex setups.

    Please don’t hesitate to reach out if there are any further questions or clarifications. :)

  19. v-aparnajyothi-y
    assigned
    v-aparnajyothi-y
    and unassigned
    dsame
    on Jan 5, 2026
  20. v-aparnajyothi-y commented on Jan 5, 2026

    @v-aparnajyothi-y
    v-aparnajyothi-y
    on Jan 5, 2026
    Contributor
    More actions

    Hello everyone, a gentle follow-up to check if there are any remaining questions, concerns, or clarifications needed around the approach documented in #696.

    If there are additional use cases or gaps you’d like us to revisit, please feel free to share. We’re happy to continue the discussion and help where possible.

  21. fingon commented on Jan 5, 2026

    @fingon
    fingon
    on Jan 5, 2026
    More actions

    To reiterate the earlier comments, documenting a workaround does not feel same as providing the feature that I (among others) need. At least I am not sticking that workflow blob to (number of) repos that need it, and having ~one-liner to do this would be much better.

    I just live with suboptimal cache usage where it doesn't matter and burn some free GHA minutes. Where it actually costs me/us money, I have already done similar (but bit simpler as I don't need to e.g. care about Windows) hacks.

    Reacted by Edward Muller
  22. v-aparnajyothi-y commented on Jan 29, 2026

    @v-aparnajyothi-y
    v-aparnajyothi-y
    on Jan 29, 2026
    Contributor
    More actions

    Hello @fingon, Thanks for your input! Currently, #696 documents how to restore cache using existing workflows, but we understand it doesn’t provide a simple one-liner for “restore-only.”

    We’re monitoring community interest and may revisit this in the future. For now, actions/cache remains the recommended approach for advanced or customized caching needs.
    Please don’t hesitate to reach out if there are any further questions or clarifications. :)

  23. v-aparnajyothi-y
    removed their assignment
    on Jan 29, 2026
  24. atoulme commented on Feb 13, 2026

    @atoulme
    atoulme
    on Feb 13, 2026
    More actions

    What is the threshold for community interest?

    Reacted by Edward Muller and wizardist
  25. atoulme commented on May 26, 2026

    @atoulme
    atoulme
    on May 26, 2026
    More actions

    Hello folks, this issue has 30 upvotes as of today. Is this enough to warrant revisiting?

    I have a PR with a 5 line change to implement this.

    Reacted by Nelz, Markus Stenberg, Benjamin Rea and Taras
  26. atoulme commented on Jul 21, 2026

    @atoulme
    atoulme
    on Jul 21, 2026
    More actions

    I have not heard back. Any chance we can get a response here?

  27. jamestelfer
    added 3 commits that reference this issue on Sep 25, 2026

    ci: write the Go cache from the unit tests only

    97c9200

    ci: cache Go builds with one writer per cache and no test results

    44f639e

    ci: cache Go builds with one writer per cache and no test results

    98686d0
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.