Optimize Wordpress to Score an A with YSlow
I finally took the time to setup Wordpress for myself this week. After I completed the installation (wow, that was fast!), I had the idea to see if I could optimize the delivery of the content. Yahoo! has created a Firefox plugin, YSlow, which reports on several different aspects of a web site’s delivery and structure, and rates each category on an A to F scale.I thought it might be a fun exercise to try to optimize Apache based on the feedback that YSlow provides to see how high a score I could get for this blog. So far, I’m at 93 (an A).
Here are the steps I took in my Apache configuration file.
- Enabled g-zip compression for text-html.
- Enabled Expires Headers for images in the /images folder.
- Turned off etags because I wasn’t using them.
Here are the configuration settings that I added to the .conf file:
<Location />
# Insert filter
SetOutputFilter DEFLATE
# Netscape 4.x has some problems...
BrowserMatch ^Mozilla/4 gzip-only-text/html
# Netscape 4.06-4.08 have some more problems
BrowserMatch ^Mozilla/4\.0[678] no-gzip
# MSIE masquerades as Netscape, but it is fine
# BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
# NOTE: Due to a bug in mod_setenvif up to Apache 2.0.48
# the above regex won't work. You can use the following
# workaround to get the desired effect:
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
# Don't compress images
SetEnvIfNoCase Request_URI \
\.(?:gif|jpe?g|png)$ no-gzip dont-vary
# Make sure proxies don't deliver the wrong content
Header append Vary User-Agent env=!dont-vary
</Location>
<location /blog/wp-content/themes/default/images/>
ExpiresActive On
ExpiresDefault "access plus 1 month"
# Disable etags
FileETag none
</location>
Let me know if you have any other ideas on improving your YSlow score. Next step: optimize a DotNetNuke site using YSlow.

June 18th, 2008 at 4:33 pm
That all looks great, but instead of gZipping the html only you should try zipping the CSS and JS files as well. I use the following to gzip html, css and js.
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript text/x-javascript application/javascript application/x-javascript
I think this would replace the line ‘SetOutputFilter DEFLATE’ in your example above. If you try it let me know if it gets you any higher!
I use a similar combination of things and can only get mine to B (88), i think because I have a lot of stuff going on