Remove unnecessary Cache-Control headers from 4xx/5xx error responses#20
Draft
Remove unnecessary Cache-Control headers from 4xx/5xx error responses#20
Conversation
…ponses Co-authored-by: chipitsine <2217296+chipitsine@users.noreply.github.com>
Co-authored-by: chipitsine <2217296+chipitsine@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Remove cache-control header for 502 responses
Remove unnecessary Cache-Control headers from 4xx/5xx error responses
Jan 23, 2026
a8bc83b to
2a07dc9
Compare
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. Per RFC 7234, only 2xx/3xx responses are cacheable by default, making this header redundant on error responses.Changes
src/http.c: Removed
Cache-Control: no-cache\r\nline from all 4xx error templates (400, 401, 403, 404, 405, 407, 408, 410, 413, 414, 421, 422, 425, 429, 431) and all 5xx error templates (500, 501, 502, 503, 504)Example errorfiles: Updated
examples/errorfiles/*.httpto match new formatTest errorfiles: Updated
reg-tests/http-errorfiles/errors/*.httpto match new formatExample
Before:
After:
Note: 200 OK response retains
Cache-Control: no-cacheas it's used for health checks where caching is undesirable.Original prompt
This section details on the original issue you should resolve
<issue_title>improve adding headers</issue_title>
<issue_description>### Your Feature Request
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