Repository navigation
Clear cache #2
Description
Activity
We will evict the least recently accessed cache automatically. Eventually we will add a way to clear out the cache from the UI.
Reacted by Kristian Sloth Lauszus, Shohei Ueda, Shibu Lijack, Wipe, Bengt Brodersen, Victor Hiairrassary, Christoph, Steven Cook, Jonathan Cornaz, Jeon Suyeol and 64 moreMaybe it could be a part of something to list the individual caches and their sizes in the UI and allow clearing only specific caches ?
Caches will all expire eventually so I don’t think being able to clear specific ones is going to be very useful.
Reacted by Alexis Tyler, Matthew Steedman, Sajith Neyomal, Ahmad Nassri, Max Howell, wangsongc, Samuel Williams, Jakub Kozłowski, Ryan Gustafson, Jacob Pratt and 224 moreReacted by Ahmad Nassri, Samuel Williams, Phil Rukin, Aadesh Shrestha, Matt, Sergey Bespalov, Gong Dewei, kcgen, recursion-ninja, Akira Ajisaka and 19 moreReacted by Ahmad Nassri, Samuel Williams, Aadesh Shrestha, ADmad, Michael Görner, Arshan Khanifar, Théo "Bob" Massard, Gary Robinson, Victor Melo and haxscramperCaches 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
Reacted by Julio Gómez Díaz and CodyMy 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.
Reacted by Jonathan Cornaz, Alexis Tyler, Giulio Troccoli-Allard, Daniel Steele, Wolfgang Fahl, Vincent Rubinetti, John Hollowell and Ruslan BaratovIn 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
keyfor thecacheaction.Reacted by Hugo van Kemenade, Patrick Dattilio, Mike McCall, Christian Mehlmauer, Giulio Troccoli-Allard, Ondrej Baranovič, wvengen, Simon Michael, Thomas Eizinger, Ryan Gustafson and 27 moreSame 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
Reacted by Can Rau, Philipe Fatio, Stanislav Dimitrov, Nick Maludy, Willow Chargin, ice0, Jared Malcolm, Hugo van Kemenade, Dan Keenan, Daniel Steele and 21 moreThought I'd ping this as well. Running into cache issues after the repo's name was changed.
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?
Reacted by Josey Morton, Matt Ratzke, Takase, konradfischer, Benno and Jussi Palo@knubie Change the key (and restore keys). For example, you could add
-v2-to the key.Reacted by Matthew Steedman, Can Rau, Hugo van Kemenade, Bengt Brodersen, Gerardo Navarro, Wolfgang Fahl, Takase, konradfischer and nathanfrankeWould 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
Reacted by Jirka Borovec, Matthew Steedman, wvengen, Gregor Albrecht, Samuel Williams, Hugo van Kemenade, Evan, Gerardo Navarro, Wolfgang Fahl, Christian Mülhaupt and 5 moreRunning into the same issue. Cached the wrong directory, the cache archive is empty and cannot regenerate it.
130 remaining items
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.
Reacted by Ben Wakeford, Miguel O. Carvajal and Mark NuzzI 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.
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.ymlFor 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.
Hi there, anyone managed to call this in GHA?
It works without any issue locally, but in the CI I keep gettingResource not accessible by integration (HTTP 403).
I feel like I tried all possible combination ofGITHUB_TOKENGH_TOKEN,secrets.GITHUB_TOKEN,github.token,permissionsand so on...@AntoinePrv You can see my example that I linked above. And two things in this example are related with your question.
- You need to add permission
permissions: actions: write # this permission is needed to delete cache
GITHUB_TOKENworks 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.
Reacted by Antoine Prouvost- added a commit that references this issue
on Oct 31, 2025 - added a commit that references this issue
on Nov 19, 2025 - added a commit that references this issue
on Mar 11, 2026 - added 2 commits that reference this issue
on Aug 2, 2026 - added a commit that references this issue
on Aug 27, 2026 - added a commit that references this issue
on Sep 21, 2026
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.