Я пытаюсь сжатие GZIP в файле .htaccess
, я протестировал HTML-страницы, и все они сжаты по какой-то причине, это не сжимает мои javascripts
и css
файлы?
Кто-нибудь знает код для добавления в файл htaccess
чтобы убедиться, что все элементы сжаты на веб-сайте?
Вы уверены, что вы также включаете расширения js и css?
<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
# filetypes to cover
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>
В качестве альтернативы:
<IfModule mod_deflate.c>
#The following line is enough for .js and .css
AddOutputFilter DEFLATE js css
AddOutputFilterByType DEFLATE text/plain text/xml application/xhtml+xml text/css application/xml application/rss+xml application/atom_xml application/x-javascript application/x-httpd-php application/x-httpd-fastphp text/html
#The following lines are to avoid bugs with some browsers
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
</IfModule>