Skip to content

Cache empty chunked responses#13410

Open
bneradt wants to merge 1 commit into
apache:masterfrom
bneradt:cache-empty-chunked-responses
Open

Cache empty chunked responses#13410
bneradt wants to merge 1 commit into
apache:masterfrom
bneradt:cache-empty-chunked-responses

Conversation

@bneradt

@bneradt bneradt commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Empty chunked responses never start a cache write VIO, so ATS aborts
the cache entry and sends later requests back to the origin.

This starts a zero-byte cache write and preserves the empty-document
state through cache setup. It also adds coverage for negative and
successful responses.

Fixes: #11313

Empty chunked responses never start a cache write VIO, so ATS aborts
the cache entry and sends later requests back to the origin.

This starts a zero-byte cache write and preserves the empty-document
state through cache setup. It also adds coverage for negative and
successful responses.

Fixes: apache#11313
Copilot AI review requested due to automatic review settings July 20, 2026 21:59
@bneradt bneradt added this to the 11.0.0 milestone Jul 20, 2026
@bneradt bneradt self-assigned this Jul 20, 2026
@bneradt bneradt removed the AuTest label Jul 20, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a cache correctness gap where chunked responses with an empty body could fail to commit cache metadata (leading to later requests going back to origin), and adds replay-based coverage to prevent regressions. The change is implemented by ensuring cache writes create a VIO even for zero-byte bodies and by teaching the cache write path to treat an explicit zero-byte write as an empty document.

Changes:

  • Start a zero-byte cache write VIO for empty-body cache writes so closing the cache VC commits (rather than aborts) the entry.
  • Mark zero-byte cache writes as “empty document” in CacheVC and ensure object size is set to 0 in that case.
  • Extend the negative-caching replay to cover empty chunked bodies for both negative (404) and successful (200) responses.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
tests/gold_tests/cache/replay/negative-caching-300-second-timeout.replay.yaml Adds replay coverage for caching empty chunked 404 and 200 responses (issue #11313).
src/proxy/http/HttpTunnel.cc Ensures cache-write consumers get a VIO even when the computed write size is 0.
src/iocore/cache/CacheVC.cc Treats do_io_write(..., nbytes=0, ...) as an empty-document write and propagates that into cache metadata handling.

Comment on lines +213 to +217
if (nbytes == 0) {
// A zero-byte write represents an empty document, while closing without a
// write represents a header-only update.
f.allow_empty_doc = 1;
if (alternate.valid()) {
@bneradt
bneradt requested a review from ezelkow1 July 20, 2026 22:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: No status
Status: No status

Development

Successfully merging this pull request may close these issues.

Zero byte chunked errors are not cached

2 participants