Skip to content

mod_cache_socache: Preserve the cached body across a 304 revalidation. - #1147

Open
arturobernalg wants to merge 1 commit into
apache:trunkfrom
arturobernalg:fix/bz69512-socache-revalidate-body
Open

arturobernalg wants to merge 1 commit into
apache:trunkfrom
arturobernalg:fix/bz69512-socache-revalidate-body

Conversation

@arturobernalg

@arturobernalg arturobernalg commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

On a 304 refresh mod_cache_socache rewrote the cached entry with just the new headers and dropped the body, so the resource came back empty on the next hit — it keeps headers and body together in one socache blob, unlike mod_cache_disk whose body is a separate file. This carries the cached body across the header update in store_headers(), before the entry is committed, so a refresh no longer loses it. Reproduced on trunk with socache_shmcb, and a new test under test/modules/cache covers it. Bugzilla: https://bz.apache.org/bugzilla/show_bug.cgi?id=69512

  • This PR does not report or address a security vulnerability.
  • Code follows the httpd style guide.
  • New log messages use an APLOGNO() tag.
  • A changes-entries/*.txt file is included.
  • Test cases based on pyhttpd are included.

@arturobernalg
arturobernalg force-pushed the fix/bz69512-socache-revalidate-body branch from 2e9b125 to 806cb05 Compare December 1, 2026 20:45
store_headers() rebuilds the single socache blob (headers followed by
body) in a fresh buffer every time the stored headers are updated. On a
conditional revalidation the generic cache calls store_headers() and
commits the entry without calling store_body() again, so the rebuilt
blob held the new headers but no body, and commit_entity() stored a
body-less entry. The next request recalled an empty body and served a
truncated response.

Carry the previously cached body, loaded by open_entity() into
sobj->body, into the rebuilt buffer before commit_entity(), so the body
survives a header-only update. This matches mod_cache_disk, where the
body is kept in a separate file that revalidation leaves untouched.

PR: 69512
@arturobernalg
arturobernalg force-pushed the fix/bz69512-socache-revalidate-body branch from 806cb05 to 95f2083 Compare December 1, 2026 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant