Skip to content

Cdn cache misc#2862

Merged
david-a-wheeler merged 3 commits into
mainfrom
cdn_cache_misc
Jun 26, 2026
Merged

Cdn cache misc#2862
david-a-wheeler merged 3 commits into
mainfrom
cdn_cache_misc

Conversation

@david-a-wheeler

Copy link
Copy Markdown
Collaborator

No description provided.

david-a-wheeler and others added 2 commits June 26, 2026 11:24
Document-only changes to the planned-future-work section for caching
miscellaneous static pages:

- 10.2: clarify the table names canonical locale-prefixed URLs (e.g. /en),
  and that the locale-less form is never the cached object (it 302-redirects
  uncached via redir_missing_locale).
- 10.3: add a caveat that cache_static_page_on_cdn is a before_action that
  commits cache headers before the body, so qualifying actions must never
  gain an internal redirect; otherwise move to an in-action
  "return if performed?" guard as projects#show does.
- 10.5: add a "locale-less static paths redirect uncached" test asserting
  each bare path 302s with private, no-store and no Surrogate-Control,
  locking in that the Accept-Language-dependent redirect is never cached.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: David A. Wheeler <dwheeler@dwheeler.com>
Implement the planned CDN caching of anonymous, static-after-boot pages
(home, cookies, criteria discussion/stats, criteria index/show) using the
same machinery as the project-show caching: conditional CSRF meta tag,
cache_on_cdn / omit_session_cookie, and the existing Fastly cookie-bypass
rule. No new Fastly config is required.

- ApplicationController: add CACHE_UNCHANGING_PAGES kill switch
  (BADGEAPP_CACHE_UNCHANGING), the shared UNCHANGING_SURROGATE_KEY
  ('unchanging'), and the cache_unchanging_page_on_cdn guard (caches only
  anonymous, flash-free HTML).
- StaticPagesController / CriteriaController: attach the guard as a
  before_action on the qualifying actions. "cookies" intentionally has no
  action method (it would shadow ActionController::Cookies#cookies), so the
  Rails/LexicallyScopedActionFilter cop is narrowly disabled there.
- config/puma.rb: after_booted hook purges the shared key on boot, plus a
  delayed re-purge to beat the rolling-deploy race (reuses
  PurgeCdnProjectJob). Uses after_booted (Puma 7 deprecated on_booted).
- Tests: extend CdnCachingTest with cacheability (shared surrogate key,
  across en+fr locales), the byte-identical invariant, logged-in bypass,
  carried-over-flash bypass, locale-less-redirect-uncached, and a guard
  that the runtime-changing Atom feed is never cached.
- Name the concept "unchanging" (rendered output does not change until the
  next deploy) rather than "miscellaneous"; update docs Section 10 to match.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: David A. Wheeler <dwheeler@dwheeler.com>
@david-a-wheeler

Copy link
Copy Markdown
Collaborator Author

This caches, on the CDN, the "unchanging" pages that don't change once the system starts such as /en when there is no personalizing session cookie. Again, our goal is to reduce the load on our back-end.

@codecov

codecov Bot commented Jun 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (c060a97) to head (645ebfa).

Additional details and impacted files
@@            Coverage Diff            @@
##              main     #2862   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           79        79           
  Lines         4332      4342   +10     
=========================================
+ Hits          4332      4342   +10     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 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.

Reduce system-test flakiness by implementing
two driver-layer changes in test/application_system_test_case.rb:

- Pass Chrome's --disable-dev-shm-usage so the renderer uses /tmp instead
  of the small (often 64MB) /dev/shm. Under load /dev/shm fills, the
  renderer crashes, and the dead browser session cascades into spurious
  errors in later tests. This is the standard fix for that cascade.
- Raise Capybara.default_max_wait_time from 5s to 10s. The polling helpers
  (ensure_choice, wait_for_jquery, wait_for_url) derive their Timeout
  budgets from this; under contention 5s was too tight and they timed out
  together. 10s costs nothing on the happy path.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: David A. Wheeler <dwheeler@dwheeler.com>
@david-a-wheeler david-a-wheeler merged commit 542c6e7 into main Jun 26, 2026
8 checks passed
@david-a-wheeler david-a-wheeler deleted the cdn_cache_misc branch June 26, 2026 16:52
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