Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cache handling bug with validation callback #454

Merged
merged 1 commit into from
Jun 28, 2024
Merged

Conversation

sirosen
Copy link
Member

@sirosen sirosen commented Jun 28, 2024

The validation_callback invocation in CacheDownloader forced redownloads even on a cache hit, in order to pass the response content to a parser.

After experimenting with several solutions, the easiest is to abstract out validation_callback into an arbitrary response_ok call which gets passed into the request fetching loop. response_ok is then a wrapper over the validation callback which can intentionally answer "yes" eagerly if a response evaluates to a cache hit -- a response which is a '200 Ok' and contains a Last-Modified header which scans as a hit should be treated as 'ok' regardless of its content.

In addition to the code changes, a regression test is included, which is demonstrated to fail on the current release.

resolves #453

The validation_callback invocation in CacheDownloader forced
redownloads even on a cache hit, in order to pass the response content
to a parser.

After experimenting with several solutions, the easiest is to abstract
out `validation_callback` into an arbitrary `response_ok` call which
gets passed into the request fetching loop. `response_ok` is then a
wrapper over the validation callback which can intentionally answer
"yes" eagerly if a response evaluates to a cache hit -- a response
which is a '200 Ok' and contains a Last-Modified header which scans as
a hit should be treated as 'ok' regardless of its content.

In addition to the code changes, a regression test is included, which
is demonstrated to fail on the current release.
@sirosen sirosen merged commit 53793e2 into main Jun 28, 2024
45 checks passed
@sirosen sirosen deleted the bugfix-cache-perf branch June 28, 2024 03:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remote file caching improvement is destroyed by use of parse as a validation callback
1 participant