-
Couldn't load subscription status.
- Fork 2.7k
Description
Current Behavior
The ETag and Last-Modified headers are cleared when the response is compressed by the Brotli plugin:
apisix/apisix/plugins/brotli.lua
Lines 225 to 226 in 0c794a0
| core.response.clear_header_as_body_modified() | |
| core.response.add_header("Content-Encoding", "br") |
apisix/apisix/core/response.lua
Lines 158 to 166 in 0c794a0
| function _M.clear_header_as_body_modified() | |
| ngx.header.content_length = nil | |
| -- in case of upstream content is compressed content | |
| ngx.header.content_encoding = nil | |
| -- clear cache identifier | |
| ngx.header.last_modified = nil | |
| ngx.header.etag = nil | |
| end |
Expected Behavior
The ETag and Last-Modified headers from the upstream server should be preserved even though the response is Brotli-compressed. Clearing these headers is not required because if the source content has not changed, then the compressed content would not change either and the browser can avoid requesting the unchanged content from the server again.
The APISIX gzip plugin appears not to clear these headers. This also indicates that clearing these headers is not required.
Error Logs
No response
Steps to Reproduce
- Build an APISIX image with the Brotli shared libraries as mentioned in the documentation.
- Prepare an upstream server that returns a response with the
ETagandLast-Modifiedheaders. - Create an APISIX route to the upstream server that enables the Brotli plugin.
- Make a request to the upstream server via APISIX with the
Accept-Encodingheader set tobrand observe that theETagandLast-Modifiedheaders are removed.
Environment
- APISIX version (run
apisix version):3.9.1 - Operating system (run
uname -a): Linux - OpenResty / Nginx version (run
openresty -Vornginx -V):nginx version: openresty/1.25.3.1 - etcd version, if relevant (run
curl http://127.0.0.1:9090/v1/server_info): Not relevant - APISIX Dashboard version, if relevant: Not relevant
- Plugin runner version, for issues related to plugin runners: Not relevant
- LuaRocks version, for installation issues (run
luarocks --version): Not relevant
Metadata
Metadata
Assignees
Labels
Type
Projects
Status