Skip to content

Add 204 and 308 to heuristically cacheable status codes#13015

Open
bryancall wants to merge 2 commits intoapache:masterfrom
bryancall:cache-heuristic-204-308
Open

Add 204 and 308 to heuristically cacheable status codes#13015
bryancall wants to merge 2 commits intoapache:masterfrom
bryancall:cache-heuristic-204-308

Conversation

@bryancall
Copy link
Contributor

RFC 9110 Section 15.1 defines 204 (No Content) and 308 (Permanent Redirect) as heuristically cacheable by default, but they were missing from the allowlist in is_response_cacheable(). This meant these responses would only be cached via negative caching configuration rather than being treated as cacheable by default like their counterparts (200 and 301).

RFC 9110 Section 15.1 defines 204 (No Content) and 308 (Permanent
Redirect) as heuristically cacheable by default, but they were missing
from the allowlist in is_response_cacheable(). This meant these
responses would only be cached via negative caching configuration
rather than being treated as cacheable by default like their
counterparts (200 and 301).
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates ATS core cacheability heuristics so that responses with HTTP 204 (No Content) and 308 (Permanent Redirect) are treated as heuristically cacheable by default (consistent with the existing allowlist behavior for similar status codes).

Changes:

  • Add HTTPStatus::NO_CONTENT (204) to the status-code allowlist in HttpTransact::is_response_cacheable().
  • Add HTTPStatus::PERMANENT_REDIRECT (308) to the same allowlist.

Verifies that responses with heuristically cacheable status codes
(200, 203, 204, 300, 301, 308, 410) are cached when only
Last-Modified is present (no Cache-Control or Expires), and that
non-cacheable codes (302, 307, 400, 403) are not cached.

Negative caching is disabled to isolate the heuristic path.
@bryancall
Copy link
Contributor Author

RFC 9110 Heuristic Caching Gap Analysis

While adding 204 and 308, I checked the full list of heuristically cacheable status codes from RFC 9110 Section 15.1. ATS is still missing four codes from the allowlist in is_response_cacheable():

Status RFC 9110 ATS (after this PR)
200 OK Cacheable In allowlist
203 Non-Authoritative Information Cacheable In allowlist
204 No Content Cacheable In allowlist (this PR)
206 Partial Content Cacheable Intentionally excluded -- handled by range caching logic
300 Multiple Choices Cacheable In allowlist
301 Moved Permanently Cacheable In allowlist
308 Permanent Redirect Cacheable In allowlist (this PR)
404 Not Found Cacheable Missing -- negative caching only
405 Method Not Allowed Cacheable Missing -- negative caching only
410 Gone Cacheable In allowlist
414 URI Too Long Cacheable Missing -- negative caching only
501 Not Implemented Cacheable Missing -- negative caching only

The four missing codes (404, 405, 414, 501) are currently only cached when proxy.config.http.negative_caching_enabled is turned on, and they use a flat TTL (negative_caching_lifetime, default 1800s) instead of proper LM-factor heuristic freshness.

Adding these to the heuristic allowlist would be a behavior change for existing deployments -- particularly for 404, where many operators rely on the current default of not caching 404s without explicit negative caching configuration. Keeping this PR scoped to just 204 and 308, but will open a separate issue to track the remaining gaps.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants