Cdn cache misc#2862
Merged
Merged
Conversation
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>
Collaborator
Author
|
This caches, on the CDN, the "unchanging" pages that don't change once the system starts such as |
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
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>
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.