Recently, we found a strange problem. For the nginx back-end, the squid front-end architecture, the squid output page has not been compressed. When hosts is directed to the nginx machine, the page is indeed compressed. After a long time of searching on the internet, squid does not support http1.1, so the compressed page will not be compressed after it passes through.
A strange problem was found recently. For nginx on the backend, squIdFrontendArchitecture, The page output by squid has not been performedCompression.
When hosts is directed to the nginx machine, the page is indeed compressed.
After a long time of searching on the internet, squid does not support http1.1, so the compressed page will not be compressed after it passes through.
Two days later, he reminded his colleagues that the deflate module of apache2 was compressed by squid output.
So I have to look back at the problem again. The problem is still focused on http1.1 and 1.0.
I tried to compare the apache output header with the nginx output header, and then one by one in nginxDd_ Header and proxy_hide_header took several hours. After debugging, the problem persists.
Then I think the problem is that I used the IE browser when extracting the header, so I sent all the http1.1 requests. The obtained results are not consistent with the results of squid access to the backend.
I found another machine and used curl-0 for debugging.
This debugging finally found the problem:
Curl -- header Accept-ENcOding: gZip, Deflate-D x-0 http: // apache
The aboveCommandThe output result is garbled and proved to be compressed.
Curl -- header Accept-Encoding:Gzip, Deflate-D x-0 http: // nginx
The output result of the above command is an explicit Code, which proves that it is not compressed.
Finally, the difference was found !!!
However:
Curl -- header Accept-Encoding: gzip, deflate-D x http: // nginx
After the preceding command is executed, nginx can also return the compression result.
From these phenomena, we can see that squid actually uses http1.0 to fetch data from the backend. Can apache actually support compression under http1.0? It seems that there is no compression in http1.0.
So I checked the information and found that http1.0 can be compressed.
So does nginx support 1.0 compression? Go to nginx.net to check.
Check gzip_moDuA complete configuration statement is found:
Gzip_http_version
Syntax: gzip_http_version 1.0 | 1.1
Default: gzip_http_version 1.1
ContExT: http, server, loCatIon
Turns gzipCompressIon on or off depending on the HTTP request version.
When HTTP version 1.0 is usEd, The Vary: Accept-Encoding header is notSet. As this can lead to proxy cache upload uption, consider adding it with add_header.LsO note that the Content-Length header is not set when using either version. Keepalives will therefore be impossible with version 1.0, while for 1.1 it is handled by chunkedTrAnsfers.
Added to nginx. conf, which is good. squid can return compressed content.
After a few days of headache, the problem was finally solved.
------------------------------------------------------------------
In addition, gzip_vary needs to be set to on, and the system needs to be/usr/lib/zlib. a, zlib1.2.3 installed.
./Configure -- shared -- prefix =/usr
./Configure -- prefix =/usr
Install the tool twice after compilation.
------------------------------------------------------------------
Nginx0.7.3 or earlier must be added:
Add_header Vary Accept-Encoding;
Force nginx to send vary
Otherwise, squid considers that nginx does not support compression after obtaining a non-compressed version, and then keeps the cached non-compressed version unupdated, in this case, a link returns a non-compressed version for a long time, usually the homepage.
------------------------------------------------------------------
After Vary is forcibly added for versions earlier than nginx0.7.3, the cache will expire in a few seconds. Therefore, you can only use version 0.7.3 or later to solve the problem.
Author: Ayou