Skip to content

fix: close discarded cached response bodies - #499

Closed
2Zest wants to merge 1 commit into
psf:masterfrom
2Zest:fix/close-discarded-cache-responses
Closed

2Zest wants to merge 1 commit into
psf:masterfrom
2Zest:fix/close-discarded-cache-responses

Conversation

@2Zest

@2Zest 2Zest commented Nov 9, 2026

Copy link
Copy Markdown

Description

Separate-body cache lookups can leave file-backed response bodies open when deserialization fails, conditional headers are read, or stale/invalid responses are discarded. Close every response/body that will not be returned, while preserving open responses for fresh cache hits.

Reference issue

Fixes #497.

Tests

  • git diff --check
  • python -m compileall -q cachecontrol/controller.py tests/test_cache_control.py
  • Standalone mocked regression script passed (cache close regressions passed).
  • Full pytest was unavailable because the local environment lacks cherrypy.

AI Generation Disclosure

OpenAI Codex assisted with investigation, implementation, and test drafting. I reviewed the final diff and validation output; the code and text were generated with that assistance.

@woodruffw woodruffw closed this Nov 9, 2026
@psf psf locked and limited conversation to collaborators Nov 9, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stale cache refresh fails on Windows with PyPy

2 participants