cache icon indicating copy to clipboard operation
cache copied to clipboard

Document that no cache is saved on an exact match and thus file hashes should be included in keys

Open jwodder opened this issue 5 years ago • 4 comments

The (unexpected, to me) fact that the cache isn't updated on an exact match seems to be an important point worthy of being documented, and it helps to explain exactly why hash expressions should be included in keys.

jwodder avatar Oct 20 '20 18:10 jwodder

@jwodder All our recommended workflows have hash of the files included. Like package.json or requirements.txt. So I suppose this PR is no longer needed.

Phantsure avatar Jun 06 '22 11:06 Phantsure

@Phantsure I don't think that makes a difference. Just having exact file hashes in all of the recommended workflows isn't enough to explain why they should be there.

jwodder avatar Jun 06 '22 12:06 jwodder

Exact match of the key means cache hit. When a cache hit occurs, cache wouldn't be updated as cache is already present there. When a cache miss occurs, cache will be updated for future use. It seems you are suggesting that users might not be familiar with concept of caching. Is that right?

Phantsure avatar Jun 06 '22 12:06 Phantsure

@Phantsure I'm suggesting they might not be familiar with the "When a cache hit occurs, cache wouldn't be updated" aspect of caching, yes.

jwodder avatar Jun 06 '22 12:06 jwodder

cc @vsvipul For second par of eyes. Does this change makes sense here or should it be present at all?

Phantsure avatar Aug 22 '22 10:08 Phantsure

You are suggesting to call out two things:

  • Cache is not saved on cache hit
  • Use hash of dependency files in key, so as to invalidate cache when files change.

@jwodder Is that right?

Phantsure avatar Aug 24 '22 09:08 Phantsure

@Phantsure Yes.

jwodder avatar Aug 24 '22 12:08 jwodder

  • cache not saved on hit, read below example workflow: https://github.com/actions/cache#example-workflow
  • Use hashfiles: https://github.com/actions/cache#creating-a-cache-key

All seems resolved, So I am closing this PR. Thank you for your contribution @jwodder

Phantsure avatar Oct 04 '22 09:10 Phantsure