我想gzip我的網站。但我不確定它是否真的有效..
當我在checkgzipcompression.com,WhatsMyIP.org和YSlow檢查時 - 他們都告訴我該網站沒有壓縮。 Yslow還告訴我,我有一些未壓縮的文件,當然建議我這樣做。gzipping我的網站似乎無法使用htaccess - 無內容編碼:gzip
這是一部分,我htaccess
-file,應該壓縮的網站:
<IfModule mod_deflate.c>
# Force compression for mangled headers.
<IfModule mod_setenvif.c>
<IfModule mod_headers.c>
SetEnvIfNoCase ^(Accept-EncodXng|X-cept-Encoding|X{15}|~{15}|-{15})$ ^((gzip|deflate)\s*,?\s*)+|[X~-]{4,13}$ HAVE_Accept-Encoding
RequestHeader append Accept-Encoding "gzip,deflate" env=HAVE_Accept-Encoding
</IfModule>
</IfModule>
# Compress all output labeled with one of the following MIME-types
<IfModule mod_filter.c>
AddOutputFilterByType DEFLATE application/atom+xml \
application/javascript \
application/json \
application/rss+xml \
application/vnd.ms-fontobject \
application/x-font-ttf \
application/x-web-app-manifest+json \
application/x-httpd-php \
application/x-httpd-fastphp \
application/xhtml+xml \
application/xml \
font/opentype \
image/svg+xml \
image/x-icon \
text/css \
text/html \
text/plain \
text/x-component \
text/xml
</IfModule>
</IfModule>
這個代碼是基於h5bp(https://github.com/h5bp/html5-boilerplate/blob/v4.3.0/doc/TOC.md)。
如果我將ini_set("zlib.output_compression", 4096);
添加到PHP啓動腳本 - checkgzipcompression.com和WhatsMyIP.org告訴我,我的網站是壓縮的。以kb爲單位的頁面重量。
但YSlow仍然告訴我,我有多個未壓縮的文件。
而在Chrome和Firefox的開發工具中,顯示每個請求/文件的未壓縮文件大小(我不確定它是否假設它是(?))。
它的確說Accept-Encoding: gzip,deflate
和Vary: Accept-Encoding
,但沒有什麼像Content-Encoding: gzip
。
我剛剛與我的服務器提供商BlueHost聊天,他們說mod_deflate
會在所有服務器上自動運行。但由於它是動態的,大多數網站掃描儀都沒有看到它。
結論是,我不可能真正確定我的網站實際上是壓縮的。
的.htaccess
-file是因爲它是如上圖所示,並zlib.output_compression()
被關閉 - 如果你有檢查出來的能力..
域名:http://barkeeper.thomaskile.me
這裏的acreenprint什麼firefox不得不說關於該頁面:
這個答案的確切程度如何?它看起來像一個評論,因爲它沒有提供任何解決方案或可能的原因。 – Antoniossss