Skip to content

Cache updates - #643

Merged
artoonie merged 3 commits into
mainfrom
cache-updates
Sep 12, 2026
Merged

artoonie merged 3 commits into
mainfrom
cache-updates

Conversation

@artoonie

Copy link
Copy Markdown
Owner

No description provided.

artoonie and others added 3 commits September 11, 2026 22:02
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

codecov Bot commented Sep 12, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.13%. Comparing base (be6d885) to head (87b8ba2).

Additional details and impacted files

Impacted file tree graph

@@            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     
Files with missing lines Coverage Δ
rcvis/settings.py 77.63% <100.00%> (+0.29%) ⬆️
visualizer/tests/testSimple.py 100.00% <100.00%> (ø)
visualizer/views.py 95.62% <ø> (+0.28%) ⬆️

Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update be6d885...87b8ba2. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@artoonie
artoonie merged commit b293ff3 into main Sep 12, 2026
7 checks passed
@artoonie
artoonie deleted the cache-updates branch September 12, 2026 03:06
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.

1 participant