Repository navigation
Conversation
HTTP max-age was always 86400 before stats were generated, so Camo could keep a card past midnight even after the server treated it as stale. Choose max-age after stats are known: until next midnight (capped at 24h) when the streak includes today; SHORT_CACHE_DURATION (1h) for stale or error responses. Adds unit tests for the lifetime helper.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Fixes #944.
index.phppreviously sentCache-Control: public, max-age=86400before stats were generated. GitHub Camo honors that header, so a card generated on day N could stay cached until the same wall-clock time on day N+1 — even thoughstatsMissingOrStale()would already treat it as stale after local midnight.This PR chooses the HTTP lifetime after stats (or an error) are known:
max-agestatsMissingOrStale(), missing stats, or error cardsSHORT_CACHE_DURATION)File-cache behavior (
CACHE_DURATION,statsMissingOrStale) is unchanged.Test plan
tests/HttpCacheTest.phpcovering null/zero/stale → 1h and fresh → until midnight (capped)composer test(HttpCacheTest + existing suite)cache-controlismax-age=<seconds until midnight>when the streak includes today, and ~3600 on an error / nonexistent userNotes
Issue author noted streak-length-0 already skips the file cache every request; a short HTTP lifetime there means more origin hits (and GitHub API calls). This follows the issue’s proposed solution (short lifetime when
statsMissingOrStale()is true). Happy to adjust that trade-off if maintainers prefer a longer header for the zero-streak case.