如果我理解正确,最好不要使用gzip小资源,因为它们实际上可能会变得更大,同时仍然会在CPU上遇到性能损失.所以使用gzip_min_length指令是一个明显的解决方案.但是,在运行REST API的服务器上尝试此操作时,我正在进行此操作似乎不起作用.当我收到空的json响应或非常小的响应时,Content-Encoding标头仍然存在并且正在读取"gzip".
我的问题是为什么这个设置不被NginX尊重,我该怎么做才能修复它?
API建立在Lumen微框架上.
我已经在我的nginx.conf中附加了我正在使用的Gzip设置:
# Compression
# Enable Gzip compressed.
gzip on;
# Enable compression both for HTTP/1.0 and HTTP/1.1.
gzip_http_version 1.1;
# Compression level (1-9).
# 5 is a perfect compromise between size and cpu usage, offering about
# 75% reduction for most ascii files (almost identical to level 9).
gzip_comp_level 5;
# Don't compress anything that's already small and unlikely to shrink much
# if at all (the default is 20 bytes, which is …Run Code Online (Sandbox Code Playgroud)