
내 http.conf 파일에 다음을 넣었습니다.
# mod_deflate configuration
<IfModule mod_deflate.c>
# Restrict compression to these MIME types
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/css
# Level of compression (Highest 9 - Lowest 1)
DeflateCompressionLevel 9
# Netscape 4.x has some problems.
BrowserMatch ^Mozilla/4 gzip-only-text/html
# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip
# MSIE masquerades as Netscape, but it is fine
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
<IfModule mod_headers.c>
# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary
</IfModule>
</IfModule>
내 콘텐츠가 gzip 유형의 Content-Encoding으로 반환되지 않지만 훨씬 더 많은 304가 표시되고 Etag에 +gzip 접미사가 추가됩니다. mod_deflate가 실제로 제 역할을 하고 있나요? (n00b-ishness에 대해 죄송합니다)
답변1
헤더에서 무엇을 알 수 있습니까? "content-encoding: gzip"이 반환되지 않으면 아마도 작동하지 않을 것입니다. 다음과 같이 테스트할 수 있습니다.
curl -I -H 'Accept-Encoding: gzip,deflate' http://yoursite.com/somefile
답변2
아파치 문서AddOutputFilterByType이 지시문은 Apache httpd 2.1 이상에서 더 이상 사용되지 않으며 Apache가 MIME 유형을 결정할 수 없는 경우 항상 제대로 작동하지 않음을 나타냅니다.
다음과 같은 것을 시작점으로 사용하여 압축을 활성화한 다음 모든 브라우저 조정 및 압축 수준을 다시 추가하는 것이 좋습니다. 물론 httpd.conf를 다시 확인하여 실제로 mod_deflate.so도 로드되는지 확인하는 것이 좋습니다. :
<Location />
SetOutputFilter DEFLATE
# Don't compress images
SetEnvIfNoCase Request_URI \.(?:gif|png|jpg|jpeg)$ no-gzip dont-vary
Header append Vary User-Agent env=!dont-vary
</Location>
Michael Steinfeld가 언급한 대로 cURL을 사용하여 확인하세요.
답변3
평판이 충분하지 않아 의견을 추가할 수 없으므로 답변으로 이 글을 쓰고 있습니다.
Michael Steinfeld의 원래 답변은 다음 오류를 출력하고 있었습니다(Windows 명령 프롬프트에서).
curl: (6) Could not resolve host: gzip,deflate'
콜론 뒤의 공백을 제거하여 문제를 해결했습니다.
curl -I -H 'Accept-Encoding:gzip,deflate' http://yoursite.com/somefile
답변4
와 함께LogLevel
로 설정하면 debug
mod_deflate는 디버그 메시지를 다음에 기록합니다.ErrorLog
. 압축되는 모든 리소스는 거기에서 로그아웃됩니다. mod_deflate가 실시간으로 작동하는지 확인할 수 있습니다.
tail -f /path/to/error-log | grep deflate
예를 들어
[Wed Apr 22 05:37:49.742615 2015] [deflate:debug] [pid 22627] mod_deflate.c(849): [client 127.0.0.1:55667] AH01384: Zlib: 압축 10700 ~ 2637 : URL /web/js/ common.js, 참조자:http://localhost/index.php