kieranbarnes Independent PHP, WordPress & CubeCart Programmer

Site Performance Quick Fixes

Posted on July 31, 2008

I've been playing around with YSlow for a while now, now I decided to a quick test on this blog.

This blog, according to YSlow rates a frumpy Grade D, with a score of 61. Not bad, but not great.
A bit of .htaccess trickery should give me a few extra points... Excellent Grade C, with a score of 73.
Here's the modified .htaccess file. Some of this is blatantly stolen borrowed from the AskApache Guru.

# Turn on Expires and set default to 0
ExpiresActive On
ExpiresDefault A0

# Set up caching on media files for 1 year (forever?)
<FilesMatch ".(flv|ico|pdf|avi|mov|ppt|doc|mp3|wmv|wav)$">
ExpiresDefault A29030400
Header append Cache-Control "public"
</FilesMatch>

# Set up caching on media files for 1 week
<FilesMatch ".(gif|jpg|jpeg|png|swf)$">
ExpiresDefault A604800
Header append Cache-Control "public"
</FilesMatch>

# Set up 2 Hour caching on commonly updated files
<FilesMatch ".(xml|txt|html|js|css)$">
ExpiresDefault A7200
Header append Cache-Control "proxy-revalidate"
</FilesMatch>

# Force no caching for dynamic files
<FilesMatch ".(php|cgi|pl|htm)$">
ExpiresActive Off
Header set Cache-Control "private, no-cache, no-store, proxy-revalidate, no-transform"
Header set Pragma "no-cache"
</FilesMatch>

# deflate JS and CSS
<IfModule mod_deflate.c>
        <FilesMatch ".(js|css)$">
                SetOutputFilter DEFLATE
        </FilesMatch>
</IfModule>

# Disable pesky ETags.
Header unset ETag
FileETag None

What have we done?

  • Setup caching on most of the commonly served files
  • Set Javascript and CSS files be GZipped
  • Disabled ETags.

So, jumping up a grade for just a simple cut and paste job? Can't be bad.

What else can we do? Well, theres lots. For example, I use the LightView Plus plugin, it's very JS & CSS heavy. Disabling it adds 13 points, taking me up to a score of 86. It also saves 50k of code.

Take a look at your WordPress plugins. Do you really need them all? Perhaps try loading the plugins only on the pages you require them on. cformsII lets you do exactly that!


Related posts

  1. WP Super Cache – I’m impressed
    Pictures speak better than words... WP Super Cache has shaved nearly 3 seconds off the...
  2. Using WP-Ecommerce Product Downloads without checking out
    I've used WP-Ecommerce for a few clients who required an online catalogue, rather than an...
  3. Using WordPress header and footers externally
    I needed to integrate a WordPress header (header.php) and footer (footer.php) into an external application....
  4. Shopp Alternative Google Base Feed
    So you're running a Shopp, you're going to need a Google Base Feed to stand...
  5. Using Persistent Cache in WordPress (with APC)
    Ever since WordPress 2.5, the WP Cache functions haven't been persistent, so the cached objects...

Comments (1) Trackbacks (0)
  1. Thanks a lot!


Leave a comment

(required)

No trackbacks yet.