Site Performance Quick Fixes
July 31st, 2008I’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!
| Bookmark it del.icio.us | Reddit | Slashdot | Digg | Facebook | Technorati | Google | StumbleUpon | Window Live | Tailrank | Furl | Propeller | Yahoo |
Tags: Cache, cache control, cut and paste, ETags, extra points, jpg jpeg, paste job, Performance, php cgi, proxy, quick test, score, trickery, YSlow
Was this post useful to you? Let me know, buy me a beer!
Alternatively, if you're feeling impecunious, you may like to subscribe to my RSS feed, or see other articles in the Apache, Wordpress category.