0

谷歌页面洞察建议我打开 mod_deflate,但我不明白该怎么做..

我的 htaccess 是

RewriteEngine On
RewriteBase /

SetEnv no-gzip dont-vary

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(.+?)/{2,}[?\s] [NC]
RewriteRule ^ /%1/ [L,R=301]

RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI}  [R=301,L] 

RewriteCond %{REQUEST_URI} system|application
RewriteRule ^(.*)$ index.php?/$1 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
   Header set Cache-Control "max-age=604800, public"
</FilesMatch>

我正在使用 CodeIgniter。添加SetEnv no-gzip dont-vary见解后,我可以添加mod_defale到压缩文件中......怎么做?

4

1 回答 1

0

只需将此行添加到 .htaccess 文件进行压缩:

SetOutputFilter DEFLATE

Google Page Insight 还会建议缓存,您可以使用以下代码来执行此操作:

标头集 Cache-Control "max-age=604800"

这现在适用于所有文件。您可以/应该通过正则表达式过滤文件名,<FilesMatch>因此不适用于所有文件。

于 2014-06-26T15:16:25.410 回答