2015-06-04 107 views
1

我使用谷歌網頁速度洞察當時並建議我的CSS的網頁是compressed.So我加入這個htaccess的壓縮CSS是不能在Firefox和Safari瀏覽器IPHONE工作

<filesMatch "\.(js|css)$"> 
Header set Content-Encoding x-deflate 
# Header set Content-Encoding compress 
# Header set Content-Encoding x-gzip 
</filesMatch> 

因此它被壓縮CSS和工作精細鍍鉻,但在Firefox當我訪問http://fasttorrent.me/cdn/bootstrap.css CSS鏈接是空白的,我得到以下錯誤

The character encoding of the plain text document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the file needs to be declared in the transfer protocol or file needs to use a byte order mark as an encoding signature. 

所以我添加下面的代碼

<filesMatch "\.css$"> 
FileETag None 
<ifModule mod_headers.c> 
Header set Content-type "text/css" 
</ifModule> 
</filesMatch> 

但我仍然在firefox和iphone safari中出現同樣的錯誤。

編輯:我試圖設置字符集像below..still錯誤

<filesMatch "\.(html|css|js)$"> 
AddDefaultCharset UTF-8 
DefaultLanguage en-US 
Header set Content-Encoding x-deflate 
</filesMatch> 
+0

錯誤抱怨字符集,而不是MIME類型。 –

+0

我該如何定義字符集 – Vishnu

回答

0

我前面已經有類似的問題,它看起來像Firefox不支持以下行,因爲他們宣稱輸出被壓縮但不實際壓縮它。 https://support.mozilla.org/en-US/questions/1063554

<filesMatch "\.(js|css)$"> 
Header set Content-Encoding x-deflate 
# Header set Content-Encoding compress 
# Header set Content-Encoding x-gzip 
</filesMatch> 

所以按照這個鏈接https://varvy.com/pagespeed/enable-compression.html我用下面的代替它,現在一切似乎是工作。

相關問題