0

Google page insights suggesting me to turn on mod_deflate, but I don't understand how to do it..

my htaccess is

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>

and I'm using CodeIgniter. After adding SetEnv no-gzip dont-vary insights offered my to add mod_defale to compress files... how to do it?

1 Answers1

0

Just add this line to .htaccess file for compression:

SetOutputFilter DEFLATE

Google Page Insight will also suggest caching, you can do this with this lines:

Header set Cache-Control "max-age=604800"

This is now applied to all files. You can/should filter via regex on filename with <FilesMatch> so is not applied on all files.

Jo VdB
  • 2,016
  • 18
  • 16