Cache updates - #643
Merged
Merged
Cache updates#643
Conversation
Django 5.1+ UpdateCacheMiddleware refuses to store responses whose Cache-Control contains no-cache, so the visualize views were no longer being cached server-side once Django was bumped, and every hit recomputed the graph. The no-cache header never reached real browsers anyway: the Cloudflare cache rule ignores the origin's Cache-Control and serves these pages with its own Browser TTL of 5 minutes. Freshness after an update comes from the purge on save, not from this header. Remove the custom middleware that existed only to reconcile no-cache with Django's page cache, and use the stock UpdateCacheMiddleware. Set CACHE_MIDDLEWARE_SECONDS to 300 so local development sends the same max-age Cloudflare imposes in production, rather than looking fresher (the old no-cache) or staler (Django's default 600) than real users see. Last-Modified, the 304 short-circuit, and the no-store on the embed's "not found" page are unchanged. Cache hits still do zero DB queries. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013JDT5wxbhPUtZG1kXPZ1Xe
Django 5.2's IntegerChoices has more base classes, pushing these four enums past pylint's max-parents of 7. Needed for the Django 5.2 bump. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013JDT5wxbhPUtZG1kXPZ1Xe
rcvis.com serves a million viewers of a handful of visualizations within an hour from one small server, which only works if a single viewer per page ever reaches the database. Lock that in: - test_visualization_headers_allow_shared_caching asserts the /v/, /ve/ and /vb/ responses are storable by a shared cache: max-age present, no no-cache/no-store/private, no Vary: Cookie, no Set-Cookie. Each of those would silently split the cache per viewer or disable it. - test_second_viewer_never_touches_the_database has a logged-in client populate the cache, then a separate anonymous client fetch the same page with zero DB queries and identical content. scripts/check-live-cache.sh runs the equivalent checks against the live site: cf-cache-status must be HIT through Cloudflare, and, given the Heroku origin URL, the origin response must carry cacheable headers and a second request must come from Django's page cache (unchanged Expires). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013JDT5wxbhPUtZG1kXPZ1Xe
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #643 +/- ##
==========================================
+ Coverage 96.10% 96.13% +0.02%
==========================================
Files 133 132 -1
Lines 6344 6358 +14
==========================================
+ Hits 6097 6112 +15
+ Misses 247 246 -1
Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
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.
No description provided.