Cache always hits even when the files change
See original GitHub issueI’m using GH actions to publish a static site that reflects the current OpenShift versions. The code generates a json file every time it is executed and then it renders an html file. I use the cache action to cache the pip dependencies successfully and I want to use the cache to do the same but for the json file that is generated like so:
- name: versions.json cache
uses: actions/cache@v2.1.1
env:
cache-name: versions-json
with:
path: versions.json
key: ${{ env.cache-name }}-${{ hashFiles('versions.json') }}
But it turns out that the cache always hits even if the file changes…
I’ve tried different combinations of the key such as ${{ env.cache-name }}-${{ hashFiles('**/versions.json') }}
but the cache is never ‘refreshed’.
The repo is https://github.com/openshifttips/openshift-versions/ just in case.
Thanks!
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:8 (3 by maintainers)
Top Results From Across the Web
Getting cache hit even when changing appendedCacheKey
If I change appendedCacheKey between runs I still get a cache hit. ... The basic problem is that we do not use a...
Read more >Caching Behavior of Web Browsers - F5 Networks
When a user visits a web page, the contents of that page can be stored in the browser's cache so it doesn't need...
Read more >When hitting F5 just isn't enough! - Refresh your cache
In some (rare) cases, even though you are using shift-refresh to get new data from a webpage, the pages still seem to be...
Read more >Make use of long-term caching - web.dev
This approach tells the browser to download the JS file, cache it and use the cached copy. The browser will only hit the...
Read more >How to force browsers to reload cached CSS and JS files?
css or .js file EVERY time you load the page. This method still allows caching until you actually change the file and really...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@iranzo The example above with the
run_id
in the key should work for that scenario, but it will be saving to the cache each run even ifversions.json
doesn’t change.This is really a limitation of how (or more correctly: when) cache keys are calculated. There is a feature request to address this (https://github.com/actions/cache/issues/135), but this hasn’t been worked on yet as far as I know.
It looks like the
github.run_id
variable did the trick 😃 Final result looks like this:Thanks!!!