Wordpress Optimizations – YSlow, PHP Speedy, DB Cache, Hyper Cache, and CSS Sprites

Wednesday, May 20th, 2009

YSlowGrade I’ve been researching and learning about speed optimizations for Wordpress for the last couple of months. Bluehost has always been slow for me in Vietnam, and while I didn’t think I could change that in the end (I am not so sure it is their fault really), why not try to do some enhancements?

In the end, after spending many hours reading and trying out different things, here are my suggestions. I won’t go into too much detail on everything, if you’re hard core, you’ll be able to read up by yourself, but let’s assume you just want to do some quick and easy things to noticeably help your blog site out.

That’s what this guide is for.

First, look into installing Firebug and YSlow (the screenshot above is YSlow running for my site) for Firefix: Firebug and YSlow (you need Firebug in order to run YSlow) are Firefox extensions from Yahoo that helps you understand how your site is slow. Oftentimes, it’s not just purely the max download size of your site that causes slowdown, it’s how the files are processed by your browser- the best comparison I can think of, though not entirely accurate, is traffic on a freeway. Let’s say you have 100 cars. If you have 5 lanes, 20 cars per lane may not be so bad. But if you put all 100 cars into just one lane, there will be major slowdown. Using tools like YSlow can help you see if you’re really using all 5 lanes for your web site. When running YSlow, remember to choose “Small Site or Blog” under “Rulesets" in the upper middle area of the interface. YSlow (Why Slow?) will give you a numeric grade based on how well optimized your site is (I got 100%!). Again, it doesn’t guarantee that your site is fast, it’s more about finding big issues that you may be able to fix and YSlow has great documentation to explain what each of their scores mean.

Of course, how to actually improve the scores is the hard part, so let’s identify some ways that can help with the common problems identified by YSlow.

  1. PHP Speedy. PHP sites often use PHP Speedy in order to help quicken things, and guy who wrote it has done a Wordpress-specific version as well. I’ve compared it to other plugins or sets of plugins that do similar things, but PHP Speedy seems to to the best choice. Be wary of running multiple plugins that do the same thing, as that could could slower speeds. PHP Speedy by default loads JavaScript files at the top of your CSS, but you can hack it so it will load at the bottom (your site will feel like it’s loading faster). You can also let Speedy gzip and minimy (basically makes your files smaller) your site for smaller downloading size, though you should let your server handle that if possible, like in your .htacess file
.
  2. Your .htaccess is another big way to not only make your site more secure but also improve its speed. If you’re not sure what this is, basically look for this file in your root directory. Here are some optimizations in mine, which include Zlib compression, .htaccess file protection from outside access, some basic DOS-attack prevention, cache optimization, and ETags settings. If you get any errors, you may want to check with your Hosting Service to make sure they support all the settings below; it took me a long time to figure out which compression settings would work on Bluehost. Just paste this in your root .htaccess file:

    # php_flag zlib.output_compression On

    # protect the htaccess file
    <files .htaccess>
    order allow,deny
    deny from all
    </files>

    # disable the server signature
    ServerSignature Off

    # limit file uploads to 10mb
    LimitRequestBody 10240000

    #ETAGS/CACHE

    FileETag MTime Size
    <ifmodule mod_expires.c>
      <filesmatch "\.(jpg|gif|png|css|js)$">
           ExpiresActive on
           ExpiresDefault "access plus 1 year"
       </filesmatch>
    </ifmodule>

    # disable directory browsing
    Options All -Indexes

  3. FastCGI: Ask your hosting service about it.
  4. cSprites: cSprites uses a technique called CSS Sprites to eliminate multiple loading of images. Let’s say you have 10 different images on your post. Instead of making the browser download 10 images (browser has to ask the server 10 times, back and forth), you can combine all those images into 1 larger image. The user can’t tell the difference in terms of the images, but on the system, it’s usually faster overall this way. One problem I noticed, however, is that it may not work with caching plugins well
, which I discuss next.
  5. Caching Plugins: Most people probably know about WP Super Cache. WP Super Cache is a super popular caching plugin, but I’ve been using DB Cache and Hyper Cache. Some people, including me, have tried using both together, and like the results. I have been using both for a couple of months and I like what I see so far.YSlowStats Like I said though, cSprites isn’t quite 100% compatible with caching plugins yet, but the author has said he’s working on a version that will be.

So there you go. If you don’t know how to install plugins or have a friend who can help, then I suggest not tampering with anything as if something goes wrong, you won’t know how to get the site back up.

As for I Spit Hot Fire, with these new changes you should hopefully feel that the site is fairly quick (especially if you’re from the US), but if you don’t let me know!

With the caching settings enabled in my .htaccess file, you should also notice that your browser downloads virtually nothing each time you come back to the site (see screenshot), really making things quick.

By the way, here are some sites that go into more detail about if your site code is validated (follows standards, is clean and causes no problems) and how fast your site really is:

Next: I’ll tackle some common plugins I like a lot, including security tools.

Tags: , , , , ,

Related posts

Windows Live Writer is a Godsend [Review]

Thursday, June 26th, 2008

International website connections from Vietnam can be very slow. That means that say you want to browse YouTube from Hanoi, the connection is much slower than if you were to connect to Clip.vn or Cyworld Studio. It’s not just because of distance, it’s more of that Vietnam only has 1 undersea cable connecting to outside of Vietnam. There used to be two, but pirates stole the other cable due to a snafu in Vietnamese politics early in 2007.

That said, this WordPress blog is hosted on Bluehost, a US provider. Access is pretty damn slow for me from Hanoi. I’d be pissed off at Bluehost, but everyone in the US says my blog is fast for them, and Bluehost has a good reputation overall, so I’m sticking with them. Writing blogs online, even accessing blogs can be a real pain the ass, so when I started to look for desktop blog writing solutions last year, Microsoft’s Windows Live Writer has been starting to get mention as a good solution even though it was just in beta.

2008-06-21_20-09-36-103

From Wikipedia:

“Windows Live Writer, developed by Microsoft, is a desktop blog-publishing application that is part of the Windows Live range of products. It features WYSIWYG authoring, photo-publishing and map-publishing functionality, and is currently compatible with Windows Live Spaces, Blogger, LiveJournal, TypePad, Wordpress, Community_Server, PBlogs.gr, JournalHome, the MetaWeblog API, the Moveable Type API, and all blogs that support RSD (Really Simple Discoverability).”

I’ve heard other people say this as well, and mention it as possibly the best solution out there, and for me at least, I love it. Cannot go without it for posting.

Here’s what the interface looks like, you can close or open different sidebars (in the screenshot, I’ve opened the bottom and right sidebars):

2008-06-21_20-47-57-837

(don’t worry, you can adjust UI colors if my orange is not your thing)

Everything you need to write posts- tags, categories, scheduling dates, inserting (and editing pictures), etc. You can preview your new post in your actual theme without needing online access too.

The only thing it can’t do (and I wouldn’t expect it to be able to) is support your Wordpress editor plugins.

Two issues so far that I’m not sure will ever be fixed, but still wouldn’t sway me from using WLW.

  1. If I upload a heavy post, one that has a lot of images or a video, WLW is likely to, from my understanding, essentially time out. Will get an error and not upload. I think this is primarily due to the speed in Vietnam. It’s not always predictable when this will happen, however. Sometimes I get the error, but the post is uploaded anyway. It’s a bit annoying.
  2. Not enough plugins. There are some good plugins, but the development (one new plugin might appear every month, one good plugin, much less often) is very slow. I’m surprised that usage of WLW is not that high, or that they’re aren’t more plugins since the software is so good.

Additional things I would ask for are more formatting options (I don’t think I can adjust font), and more blog management directly from the desktop UI (you can do some, but it’s so slow from my connection), but that’s about it. It’s a great piece of software, and it’s free. I’d pay for it though, definitely.

Key Links:

Tags: , , , , ,

Related posts

A Bit Snooty to Me, Bluehost (Customer Support)

Wednesday, June 25th, 2008

Dear Customer,

Thanks for contacting us.

We apologize for the trouble you have been having.

We run shared hosting servers, with about 500 accounts per server. This setup is what makes our hosting fees so low; but, naturally, this causes resource usage issues, namely that if one account uses too much of a type of resource, the less it can be used by the other accounts.

This is easy to administer when it comes to bandwidth and HTTP connections, because a cap can easily be set. The cap is high enough for those types of issues that most customers never even hit them, anyway.
MySQL CPU issues are another story. The problem is that there are so many variables involved in this specific area that you can really only resolve an issue once it’s been created, not before it’s happened, like with other resources.

Ultimately, what can happen, then, is that one customer on the server can abuse the MySQL resources so much that it temporarily brings MySQL down for the entire server. At this point, we can suspend that particular account easily, and force them to optimize their scripts — but not until the issue has occurred. (If an account causes this issue three times, they are suspended indefinitely.)

You need to look seriously in your “tmp/mysql_slow_queries/ folder” in your root folder, at the problems you have been having, because they are ones you are creating. You have numerous slow queries every day that are affecting not only your site, but everyone else’s on your server. Please, look through these and correct them.

We recommend that you update your scripts, but you can repair some of the tables by going into “phpMyAdmin”, then select a database in the “Repair DB:” drop down, then click the “Repair DB” button, then hit the “Go Back” link & repeat the repair for other databases in your account.

You can optimize the tables by going into “phpMyAdmin”, selecting the database, Click on the link “Check All” link, then in the “With selected:” choose the “Optimize table” option.

We appreciate your business. Thank you for using BlueHost.

(name withheld)
Level 1 Support Engineer
Bluehost.com
888-401-4678

As I’ve mentioned before on this blog, I like Bluehost. They’ve saved me with some timely backup recoveries in the past, and their response time for support has always been good. Their speed is slow from Vietnam (I ran a tracert, and there are almost 20 hops from here to their servers,) but speed from what others tell me is great in the US, and I recently paid for another year of service. (about $100 USD)

A couple of days ago, my friends in the US were telling me that this site was super slow and I contacted Bluehost to ask what could be done about it. Not blaming them, I was asking if I had done something, basically wanted to know how I could prevent such issues in the future if I were the issue.

I got the above (likely mostly based off template) e-mail in response. The biggest problem I have is with the wording.

To me, it’s a little snooty, a little snarky. Seems like he wants to say, “you or people like you are making the server slow, YOU need to get into your logs and stop slowing us down, you should not complain since you pay such low rates.

I had Emil look into my logs, and it turned out I was not the culprit for the slowdown. And yes, while my rates are good, they are not substantially low, like too good to be true or anything.

There’s no way that I can tell to review my CPU usage to see what I’m really using, or when I cause (if I do) cause such issues.

I wouldn’t mind paying a different rate for better coverage, especially global, almost like insurance. (Bluehost only has 1 plan that I could find) People who don’t abuse or get traffic from different areas can pay to get a different kind of hosting, while others who abuse can be lumped into a server with other abusers and pay different rates themselves. I definitely don’t want to be an abuser and want to be a good neighbor to the other websites hosted on my server, but this reply from Bluehost does nothing to help with that and leaves a little bit of a bad taste in my mouth.

Tags: , , , ,

Related posts

I am an Idiot (Blog was Dead for a Day)

Saturday, March 22nd, 2008


Creative Commons License photo credit: duncan

As I was erasing an unused FTP account for my site yesterday, I accidentally let it start erasing my whole website. Completely my fault.

After some research, I realized Bluehost (my host) does daily and weekly (they claim monthly, but that wasn’t available as far as I could tell) backups automatically and will restore them for free. A quick e-mail to their support, and they took care of restoring the site. For some reason their daily backup was from 2 weeks ago, and their weekly was from 1 week ago, but their customer support rep said they’ve been overhauling the system. Nonetheless, thanks guys.

Lost a week worth of posts, Jimmy’s comment on Eliot Spitzer, and general statistics data, but not too bad for this bonehead move.

Bluehost has been pretty good to me, but they’re super slow for me in Vietnam. I actually blame my ISP and Vietnam’s 1(!) undersea cable to international sites more than Bluehost since I’ve heard from friends in the US they find my site perfectly fine.

Tags: , , ,

Related posts

A Work in Progress

Monday, July 16th, 2007

Well, if you’re here, then you can tell this is a work in progress. I’m using Bluehost, which Wordpress says is a good host, or at least a super sponsored host, along with the WP platform. This is a nice basic template that I have, though I want to hack it up a bit. Unfortunately, I can’t hack at all, so it’s up to my coworker Ngoc Anh who has happily volunteered to learn some WP and help me make this the best site of all time so I can take over the world.

Bluehost seems a bit slow to me, but that could be because I’m in Vietnam and we have 1 line connecting us to the rest of the world. When I look at the total size of the site, it’s not very big at all, but I probably need a big measuring tool. (Penis joke?) Ngoc Anh is helping me finalize my logo as well, I’m excited to see how these things all fit.

Tags: , ,

Related posts