Firebird News

Tuesday, November 18, 2008

cache-control / deflate optimizations in apache

these lines can be used in .htaccess too

now we get better results with firebug/yslow (B performance grade is now , before was an F grade )

before we had 700k of html code transfered over the wire
now is ~40K for example


#Enable Cache control http://httpd.apache.org/docs/2.2/mod/mod_expires.html
ExpiresActive On
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType image/gif "access plus 1 month"
#ExpiresByType text/html "access plus 2 days"
ExpiresByType text/css "access plus 1 year"
ExpiresByType application/x-javascript "access plus 1 year"
# compress all text & html http://httpd.apache.org/docs/2.2/mod/mod_deflate.html
AddOutputFilterByType DEFLATE text/html text/plain text/xml application/x-javascript text/css
# Insert filter
SetOutputFilter DEFLATE

# Don't compress images
SetEnvIfNoCase Request_URI \
\.(?:gif|jpe?g|png)$ no-gzip dont-vary 


ps: a good idea is to disable the parameters after css !
for example we had style.css?=200
so it reloaded all background images everytime even if we specified expire time in apache

No comments: