I am using CakePHP with Apache2. Analyzing my pages with the tool PageSpeed from Google, I find two main problems. The first is that I should enable gzipping of content, the second that I should leverage browser caching for images, javascript and css files.
I have more or less found how to remedy this, but it involves changing my main .htaccess file. This doesn't look really the CakePHP way, if nothing because that .htaccess is part of the CakePHP distribution, and I have to remember to keep it when changing version. Is there a better way to do this?
For the first, I can remedy by putting
php_value output_buffering On
php_value output_handler ob_gzhandler
I also tried
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/html text/plain text/css text/javascript application/x-javascript
</IfModule>
but I didn't see any result with PageSpeed.
For the second I now use
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType application/x-javascript A8640000
ExpiresByType text/javascript A8640000
ExpiresByType text/css A8640000
ExpiresByType image/png A8640000
</IfModule>
and it kind of works, although I still get the message "The following cacheable resources have a short freshness lifetime. Specify an expiration at least one month in the future for the following resources: blah blah"