Skip to content

Name a Cache Lifetime on Every Response Ahead of an Edge Proxy - #492

Merged
ptr727 merged 5 commits into
developfrom
cf-proxy-ready
Oct 23, 2026
Merged

ptr727 merged 5 commits into
developfrom
cf-proxy-ready

Conversation

@ptr727

@ptr727 ptr727 commented Oct 23, 2026 •

Copy link
Copy Markdown
Owner

Summary

Prepares the bundle for a Cloudflare proxy in front of either site, so the sites behave the same whether or not the proxy is on. The host side tracks the proxy itself as ptr727/HomeAutomation-Config#580, and this is the Blog half of what that issue lists.

  • deploy/Caddyfile: every blog response names its own Cache-Control. Pages, feeds, the sitemap, index.json, and robots.txt answer no-cache, so a browser or an edge revalidates them and a deploy shows at once. The fingerprinted /assets/ are immutable for a year. /media/ and the root icons get an hour, which bounds how long a replaced image is still served from any copy without a purge step. The redirects answer no-cache too, since the baseline header runs ahead of them, so a changed map target is followed at the next request. Both error pages answer no-cache whatever path they stand in for, since a missing file in a cached class would otherwise keep that class's lifetime. The family pages state no-cache explicitly, beside the @svg and @code lifetimes the block already set.
  • checks/log-review.jq: keeps the last element of ClientHost. Traefik writes the whole forwarded header there when a trusted proxy sends one, and Cloudflare appends the address it saw to any chain the client sent, so the last element is the one to read and the first is client-controlled. A record with no chain is unchanged. Traefik writes the field on every line, so it carries no null guard.
  • OPERATIONS.md: names the edge as a tier above Traefik that keeps no readable record, what still reaches Traefik (every HTML, XML, JSON, and text 404), what becomes a floor (counts on cached file types), and why the 403 cross-check reads the last forwarded address.
  • deploy/README.md: a "Cache lifetimes" section with the class table.

Verification

  • Released the branch to the local staging mirror three times. check-live-urls.sh passed 1294 URLs each time, with the rules from the new release.
  • Read the served header per class on both local staging sites: the home page, feed.xml, and robots.txt answer no-cache, the stylesheet answers public, max-age=31536000, immutable, a media file and favicon.ico answer public, max-age=3600, a missing /media/ image and a missing page answer 404 with no-cache, a legacy /wp-content/uploads/ path and a feed alias answer 301 with no-cache, and the family root, /en/, /af/, and a missing path answer no-cache while crest.svg keeps its week.
  • Ran checks/log-review.jq over constructed records: a two-element chain keeps its last element, and a single address is unchanged.
  • python3 -m unittest discover -s checks/tests passed 127 tests. prose_lint.py --diff reports only the comments findings this PR's label answers, and --check sentence-length reports nothing. markdownlint reports nothing on the two edited Markdown files.
  • Local strict review: three passes ran. The first found four findings on the new prose and the jq guards, fixed in the second commit. The second found two over-long sentences and a wrong mechanism name, fixed in the third. The third found nothing.

🤖 Generated with Claude Code

A proxy that caches by file extension sits in front of neither site today,
and nothing in the bundle says how long a copy may live, so a browser guesses
from Last-Modified and an edge would apply its own defaults. Every blog
response now carries a Cache-Control: pages and feeds revalidate on every
use, the fingerprinted assets are immutable, and media is bounded to an hour
so a replaced image propagates without a purge. Both error pages answer
no-cache whatever path they stand in for, and the family pages state the same.

The log review keeps the last element of ClientHost, since a proxied request
carries the forwarded chain there and a client may prepend any value. The
operations doc names the edge as a tier above Traefik and what it hides.

Verified on the local staging mirror: the live check passes, and each class
serves the header the deploy README's table states.
The first strict review pass found the deploy README claiming a lifetime on every blog response while the redirects carry none, the operations doc and the jq comment using the edge for Cloudflare where that section means Traefik, the forwarded-chain claim missing the trust condition it depends on, and null guards on a field Traefik always writes.
The second strict review pass found two sentences over the length rule and a claim that the family block has a default header where the catch-all matcher is what reaches its redirects.
@ptr727 ptr727 added the comments Permits the comment lines the pull request adds or edits, which the prose gate otherwise refuses label Oct 23, 2026
Copilot AI lite review requested due to automatic review settings October 23, 2026 18:16
@coderabbitai

coderabbitai Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 6d6ecd65-1462-4a6e-bb3c-01505fe822e6
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 49.70%. Comparing base (1861c43) to head (c671bc6).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop     #492   +/-   ##
========================================
  Coverage    49.70%   49.70%           
========================================
  Files           10       10           
  Lines         3058     3058           
========================================
  Hits          1520     1520           
  Misses        1538     1538           
Flag Coverage Δ
python-3.13 49.70% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Redirect responses still lack an explicit cache policy, leaving stale migration targets insufficiently bounded.

1 open issue
What changed in this PR

This pull request prepares the blog and family sites for operation behind a Cloudflare edge proxy by defining cache lifetimes, documenting proxy behavior, and normalizing forwarded client addresses in log analysis.

Changes:

  • Adds explicit cache policies for assets, media, pages, family content, and error responses.
  • Documents Cloudflare’s caching and request-visibility effects.
  • Updates log analysis to use the final address in forwarded client chains.
File Reviewed changes
OPERATIONS.md Documents Cloudflare proxy behavior and forwarded-address handling for 403 analysis.
deploy/​README.md Defines cache-lifetime classes and their operational rationale.
deploy/​Caddyfile Adds cache headers for blog, family, and error responses; redirects still require an explicit cache policy.
checks/​log-review.jq Extracts the final address from forwarded client chains.

Review effort: Lite

Comment thread deploy/Caddyfile Resolved
@ptr727

ptr727 commented Oct 23, 2026

Copy link
Copy Markdown
Owner Author

A recorded local strict-review pass covers head 1e1d6c4736212bf4c07958a5d69f008850c1548c, the content this pull request carries at that commit against develop, and it recorded 0 findings.

Copilot found that the redirect handlers end the route before the baseline no-cache header ran, so a 301 carried no lifetime and a changed map target could outlive a deploy in a cache. The baseline now runs first and the file classes override it. Verified on the local staging mirror: the live check passes, a legacy media redirect and a feed redirect answer no-cache, and the media and error classes keep their headers.
@ptr727

ptr727 commented Oct 23, 2026

Copy link
Copy Markdown
Owner Author

A recorded local strict-review pass covers head c671bc6e4f025738223d64d1acc8ae82417e445f, the content this pull request carries at that commit against develop, and it recorded 0 findings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comments Permits the comment lines the pull request adds or edits, which the prose gate otherwise refuses

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants