Improving S9y performace w/ YSlow?

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
Post Reply
mattsches
Regular
Posts: 440
Joined: Sat Nov 05, 2005 9:35 pm
Location: Wiesbaden, Germany
Contact:

Improving S9y performace w/ YSlow?

Post by mattsches »

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:

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 Optimization
I also put this .htacces file into my bulletproof template folder:

Code: 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 On
This is my gzip-css.php file:

Code: 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);
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
works by making fewer HTTP requests, adding a far-future expires header, Gziping page components and minifying Javascript, CSS and HTML.
Basically, that's what the YSlow team recommends.

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
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Improving S9y performace w/ YSlow?

Post by garvinhicking »

Hi!

Actually the .css.php file from s9y should already be emitting HTTP Caching headers properly?

We need to think of people using different templates (like with templatedropdown) so uniquely caching that file will create trouble for people who change their stylesheets.

Plus, I don't really beleive in GZIP compression; it adds CPU requirements to the server for the benefit of less traffic. But IMHO traffic is more expendable than CPU power for processing GZIP, both on server and client side.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Post Reply