Remove Cache-Control headers from non-cacheable HTTP error responses#18
Merged
chipitsine merged 2 commits intomasterfrom Jan 19, 2026
Merged
Conversation
…ponses Co-authored-by: chipitsine <2217296+chipitsine@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Remove cache-control header for 502 responses
Remove Cache-Control headers from non-cacheable HTTP error responses
Jan 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
HAProxy was adding
Cache-Control: no-cacheto all error responses, including those that are not cacheable by default per RFC 9110 (e.g., 502, 503, 500). This header is redundant for non-cacheable status codes.Changes
Removed Cache-Control from non-cacheable errors:
Retained Cache-Control for cacheable-by-default errors:
Modified Files
src/http.c: Error message templatesexamples/errorfiles/*.http: Example error filesreg-tests/http-errorfiles/errors/*.http: Test fixturesExample
Before (502 error):
After (502 error):
Original prompt
This section details on the original issue you should resolve
<issue_title>improve adding headers</issue_title>
<issue_description>### Detailed Description of the Problem
when some error happen and haproxy generates 502, it also adds "cache-control: no-cache" which is not required for 502 because according to RFC only 200 and 300 codes might be cached
let us not add cache-control header when not needed
an example of vtest with 502