目標
我是新來的壓縮世界。 我想爲我的網站啓用gzip壓縮。我不確定如何以正確的方式完成。如何在我的網站上啓用Gzip並進行測試?
我已經試過
在
root/
目錄我的網站創建.htaccess
並添加這些行:AddOutputFilterByType DEFLATE text/plain AddOutputFilterByType DEFLATE text/html AddOutputFilterByType DEFLATE text/xml AddOutputFilterByType DEFLATE text/css AddOutputFilterByType DEFLATE application/xml AddOutputFilterByType DEFLATE application/xhtml+xml AddOutputFilterByType DEFLATE application/rss+xml AddOutputFilterByType DEFLATE application/javascript AddOutputFilterByType DEFLATE application/x-javascript
使用測試卷曲
我試圖運行curl -I -H 'Accept-Encoding: gzip,deflate' http://my-site.com
結果:
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 20 0 0 0 0 0 0 --:--:-- 0:00:30 --:--:-- 0
Content-Encoding: gzip
注意:內容編碼:gzip
測試使用gzip測試在線工具
我去這個網站和en我的網址。
http://checkgzipcompression.com/?url=http%3A%2F%2Fwww.bunlongheng.com%2F
結果:You're blessed! It's GZIP Enabled.
我也上測試:https://www.feedthebot.com/tools/gzip/
結果:Gzip已工作? Yes
71.6%
瀏覽器減少文件大小
我已經試過上:Safari瀏覽器,火狐和Chrome。
通過2次測試後,我想,我做得對,但是當我去我的網站:我的風格都搞砸了。隨意看看吧:here
我的控制檯不斷給我這個錯誤:
無法加載資源:淨:: ERR_CONTENT_DECODING_FAILED
能有人請解釋這是爲什麼發生?
我需要在我的php.ini
中配置任何東西嗎? 如果是這樣,我可能需要創建一個,因爲我沒有。
任何幫助將非常感激。
如果你沒有得到一些回覆,你可能要使用問題底部的'flag'鏈接,並要求版主將此Q移至http://webmasters.stackexchange.com/。祝你好運。 – shellter