Improving S9y performace w/ YSlow?
Posted: Sun Feb 17, 2008 11:46 am
Hi, I've been playing around with Yahoo's YSlow Firefox extension lately, and I tried to implement some of the changes recommended by the YSlow authors. To make it short: After a while most of my changes worked and, from what I could tell, reduced the loading time of my blog. OTOH, the "optimizations" broke the admin area because some CSS and/or JS files didn't load anymore. So I reverted my setup to the old state and decided to post here first ;O)
If anyone of you is interested in this sort of optimization although it's actually more related to server setup than to S9y, here's what I tried so far (I guess; I did this in 12/2007, so I might have had some line commented out):
I added this code to the end of my .htaccess file:
I also put this .htacces file into my bulletproof template folder:
This is my gzip-css.php file:
Another interesting source might be this Wordpress plugin that might work for other PHP applications, too. I didn't really look into what they're doing, but they say it
I will appreciate any help on this topic. Maybe we can work out some general rules on how to improve blog performance on a typical (LAMP) setup?
Thanks
- Mattsches
If anyone of you is interested in this sort of optimization although it's actually more related to server setup than to S9y, here's what I tried so far (I guess; I did this in 12/2007, so I might have had some line commented out):
I added this code to the end of my .htaccess file:
Code: Select all
# BEGIN YSlow Optimization
ExpiresActive on
ExpiresDefault "access plus 4 weeks"
ExpiresByType image/jpg "access plus 4 weeks"
ExpiresByType image/jpeg "access plus 4 weeks"
AddOutputFilterByType DEFLATE text/html text/plain text/xml
AddHandler application/x-httpd-php .css
php_value auto_prepend_file gzip-css.php
php_flag zlib.output_compression On
# END YSlow OptimizationCode: Select all
# css compression htaccess ruleset
ExpiresActive on
ExpiresDefault "access plus 4 weeks"
AddHandler application/x-httpd-php .css
php_value auto_prepend_file ../../gzip-css.php
php_flag zlib.output_compression OnCode: Select all
<?php
// initialize ob_gzhandler function to send and compress data
ob_start ("ob_gzhandler");
// send the requisite header information and character set
header ("content-type: text/css; charset: UTF-8");
// check cached credentials and reprocess accordingly
header ("cache-control: must-revalidate");
// set variable for duration of cached content
$offset = 3000000;
// set variable specifying format of expiration header
$expire = "Expires: " . gmdate ("D, d M Y H:i:s", time() + $offset) . " GMT";
// send cache expiration header to the client broswer
header ($expire);Basically, that's what the YSlow team recommends.works by making fewer HTTP requests, adding a far-future expires header, Gziping page components and minifying Javascript, CSS and HTML.
I will appreciate any help on this topic. Maybe we can work out some general rules on how to improve blog performance on a typical (LAMP) setup?
Thanks
- Mattsches