Fix #73 - Change cache to take header changes into account #78
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As per #73, the current caching implementation doesn't take header changes into account. This is still a WIP until the following is done:
Cache File Format Change
The cache file format has been updated to include the headers:
When loading the cache file, it'll upgrade the old format to the new format (backwards compatibility).
Implementation
From what I found with the current implementation, there are two states that are affected:
cache
andskip
. Theskip
state does the same work as thecache
comparison, except it compares with the current headers of the actual S3 object.The
cache()
stream can now take an option to include headers as part of the cache check:For the
cache
state, the etag and all headers set onfile.s3.headers
are compared against the cached values. If a header is added, deleted or modified, the file's state is not set tocache
.For the
skip
state, the etag and all headers set onfile.s3.headers
are compared against thenormalized response headers. If a header is added, deleted or modified, the file's state is not set to
skip
. However, because thex-amz-acl
header uses a name of a canned ACL, it can't compared since the canned ACL is transformed into a full ACL on the object. Usingclient.getObjectAcl()
could be used, to get the full ACL and then map it back to the canned name, but that seems to difficult. So, if thex-amz-acl
changes, the user should use theforce
option on thepublish()
stream.Also, the cache
headers
option is ignored when doing the comparison for theskip
state becauseskip
is used regardless of caching being enabled/disabled.Questions
cache()
stream isn't used. Should this be changed to not read from the cache unless thecache()
option is used? It could lead to confusing behavior with the current implementation.skip
state? If the user doesn't use cache, we still should be comparing headers so that the file isn't skipped when headers change. As it stands right now, having theheaders
option oncache()
doesn't totally make sense (since it affects thecache
andskip
states). Should we remove the option all together and compare all headers for both thecache
andskip
states?😄