← Back to Pull requests

Add shared caching and bearer authentication to the check view #809

Closed
unknown closed this pull request without merging on Oct 24, 2026 17:47 UTC
View on GitHub
unknown unknown commented on Oct 24, 2026 13:04 UTC
Author

Uptime monitors poll the health endpoint often, and every request runs the full set of checks. A short shared cache cuts that load and limits the damage an unauthenticated caller can do. Monitors still need fresh results, so authentication and caching stay separate features.

  • max_age (a timedelta, default 0) sends Cache-Control: public, max-age=N on successful GET and HEAD responses without an Authorization header. 0 sends no-store.

  • auth_token enables bearer authentication and falls back to HEALTH_CHECK_AUTH_TOKEN. Authenticated responses are marked no-store and run the checks.

  • allow_anonymous admits requests without an Authorization header when a token is configured. A request with a wrong token receives HTTP 403 before any check runs.

  • Vary: Authorization is set when a token is configured, so shared caches key on it as described in RFC 9111 section 4.1.

  • python manage.py check --deploy reports health_check.E001 when HEALTH_CHECK_AUTH_TOKEN is set but empty.

  • The health_check command reads HEALTH_CHECK_AUTH_TOKEN by default. --auth-token overrides it.

  • HTML, JSON, and text failures return HTTP 500 and are not cached. Atom, RSS, and OpenMetrics always return HTTP 200, so their failed results can be cached for max_age.

  • The docs cover the token setup, the three view options, and a cookbook tier that serves a public cached response and bypasses the cache for authenticated requests.
  • Diff: 182 lines (+136 / -46) across 2 files Reviewer: codingjoe Review duration: 283m
    All Vouch review confidence checks passed
    Residual risk 0.25 = Change Risk (0.59) × (1 − Review Confidence (0.58)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.59 · 182 lines diff across 2 files
    0.59
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    57%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.312
    Shallow Review Depth shallow_review_depth
    0.289
    Sensitive Paths sensitive_paths
    0.059
    Real PR Conversation Timeline
    1 comments
    "Review active on #809"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 58.0% reviewed sensitive_module
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 58.8% (MEDIUM) · Higher = larger blast radius
    58.8%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 58.0% · Lower = rushed or shallow review
    58.0%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 24.7% · Safe to merge
    24.7%