Visitar URL original
Clear cache · Issue #2 · actions/cache · GitHub
Skip to content

Clear cache #2

Description

@Lauszus

Thanks for the action. It would be great if it was possible to clear the cache as well either using the action or via the web interface.

Activity

  1. chrispat commented on Oct 31, 2019

    @chrispat
    Contributor

    We will evict the least recently accessed cache automatically. Eventually we will add a way to clear out the cache from the UI.

  2. stevencpp commented on Nov 11, 2019

    @stevencpp

    Maybe it could be a part of something to list the individual caches and their sizes in the UI and allow clearing only specific caches ?

  3. chrispat commented on Nov 11, 2019

    @chrispat
    Contributor

    Caches will all expire eventually so I don’t think being able to clear specific ones is going to be very useful.

  4. jcornaz commented on Nov 12, 2019

    @jcornaz

    Caches will all expire eventually so I don’t think being able to clear specific ones is going to be very useful.

    Please consider the following use case:

    A gradle project caching the gradle caches like this:

        - name: Gradle caches
          uses: actions/cache@v1
          with:
            path: ~/.gradle/caches
            key: gradle-cache-${{ hashFiles('**/*.kt*') }}
            restore-keys: |
              gradle-cache-

    Each build will:

    • download a recent gradle build cache
    • perform the build (using and updating the build cache)
    • upload the updated cache

    Which means the build cache will grow over time and will eventually reach the size limit.

    But expiring the old caches doesn't help, because the build always re-upload it.

    Being able to manually clear the cache from time to time, would definitely be nice and useful.

    I would personally do when:

    • I just upgraded gradle to a new major version
    • I just released a new major version of my software
  5. stevencpp commented on Nov 12, 2019

    @stevencpp

    My use case for clearing only specific caches is that I have a huge dependency that takes two hours to build, and while it may eventually expire, I really don't want to have to rebuild that unless absolutely necessary. I also have a bunch of other smaller caches, and in some cases getting the right hash at the end of the key to make it rebuild exactly when it needs to can be difficult to implement, so I'd like to just use a key either without a hash at the end, or with an imperfect hash, and manually clear only that specific cache when I know it needs to be rebuilt. My current workaround is to rename the key when I want to rebuild it, but it would be better to avoid those dummy commits and just do it from the UI.

  6. eregon commented on Jan 9, 2020

    @eregon
    Contributor

    In ruby/setup-ruby#7 we noticed an issue because using subtly different prebuilt Ruby binaries corrupts the cache.
    Being able to clear the cache when it's corrupted or contains errors would be very useful as a debugging mechanism.

    Right now the only workaround seems to use another key for the cache action.

  7. firefart commented on Feb 26, 2020

    @firefart

    Same here. Dealing with a corrupted binary in a gem cache and the only way to get rid of it is to use another key. A method to clear the cache would be nice

  8. adithyabsk commented on Mar 23, 2020

    @adithyabsk

    Thought I'd ping this as well. Running into cache issues after the repo's name was changed.

  9. added a commit that references this issue on Mar 23, 2020
  10. knubie commented on May 19, 2020

    @knubie

    I need to clear the cache to get my yarn installation working again. An interface would be nice, but in lieu of that, how can i clear it manually?

  11. dhadka commented on May 20, 2020

    @dhadka
    Contributor

    @knubie Change the key (and restore keys). For example, you could add -v2- to the key.

  12. matks commented on Jun 10, 2020

    @matks

    Would be awesome to have a way to clear cache from the UI 👍

    I am setting up a GA using Composer dependencies (using dev-master) so I need Composer to grab the very latest versions from my github repo instead of the one he has in cache

  13. ioquatix commented on Aug 12, 2020

    @ioquatix

    Running into the same issue. Cached the wrong directory, the cache archive is empty and cannot regenerate it.

  14. 130 remaining items

  15. added a commit that references this issue on Nov 11, 2022
  16. jmgilman commented on Dec 6, 2022

    @jmgilman

    Adding cache management to the UI doesn't address the use case where we need to overwrite the contents of a specific cache programmatically. We have a bit of code that does an extended evaluation, and we would like to cache the results across runs; however, trying to get the cache key unique enough to do the right thing has been non-trivial. It'd be preferable to maintain a single cache across runs and overwrite it as required, but the current implementation of the action does not support this.

    For now, it seems the best solution is calling the API to delete the cache from within the action when we need to overwrite its contents.

  17. added a commit that references this issue on Feb 3, 2023
  18. Betristor commented on Oct 12, 2023

    @Betristor

    I tried to manage the caches using timestamps and seek to find a way which could erase those outdated caches within a workflow.
    Motivation: I'm developing some optimization models. And I cached some base results for my code to compare every time I made a pull request so I could compare the difference between previous version and current version.
    Problem: The cached base results would not update as some changes are introduced and approved into the base results.
    Solution: Cache the results with timestamps and use the latest version of results. New cache will be triggered when a pull request is merged which means everything is approved including changes to the code and influence onto optimization model results.
    Only one thing left: The cache size will grow larger and larger. Some outdated caches will take the github quota.
    Fix: According to github official website, "GitHub will remove any cache entries that have not been accessed in over 7 days."

    Everything done.

  19. ihostage commented on Oct 12, 2023

    @ihostage

    Only one thing left: The cache size will grow larger and larger. Some outdated caches will take the github quota.

    @Betristor If you are sure, that cache entry is outdated, you can remove it itself with help GitHub CLI.

    For example in Playframework we remove outdated cache entries by simple script in schedule workflow
    https://github.com/playframework/playframework/blob/3a78ae68acb10e614e8b1f1411ff4f7b93cd909e/.github/workflows/delete-caches.yml

  20. Betristor commented on Oct 12, 2023

    @Betristor

    For example in Playframework we remove outdated cache entries by simple script in schedule workflow https://github.com/playframework/playframework/blob/3a78ae68acb10e614e8b1f1411ff4f7b93cd909e/.github/workflows/delete-caches.yml

    @ihostage That's quite an elegant way for my situation. Much thanks. Maybe temporarily github could do the thing for me and I will introduce this feature in later development. And each time when a new cache is generated, whether its contents are updated or not, it's outdated for me. That's why I used time stamp to tag them.

  21. AntoinePrv commented on Oct 30, 2023

    @AntoinePrv

    Hi there, anyone managed to call this in GHA?
    It works without any issue locally, but in the CI I keep getting Resource not accessible by integration (HTTP 403).
    I feel like I tried all possible combination of GITHUB_TOKEN GH_TOKEN, secrets.GITHUB_TOKEN, github.token, permissions and so on...

  22. ihostage commented on Oct 31, 2023

    @ihostage

    @AntoinePrv You can see my example that I linked above. And two things in this example are related with your question.

    1. You need to add permission
    permissions:
      actions: write # this permission is needed to delete cache
    1. GITHUB_TOKEN works only in protected branches. If you want to delete cache entry in the job for PR for example, you need to create a personal token with right permissions.
  23. added a commit that references this issue on Oct 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions