WordPress is Impressive

Categories: news — Tags: — Posted by: Grant @ February 28, 2008 : 11:39 pm

Six hours.

That’s the amount of time between downloading WordPress and having it (almost) seamlessly integrated into the website. Normally when I download any development packages, I try to budget a good deal of time to simply ramp up on new code, architecture and design. Even for a popular package like WordPress, it’s hard not to have some type of painful anticipation on how well things are going to go when you delve under the hood. My guess is that it’s somewhat akin to a Toyota mechanic who is getting their first shot looking at a new Prius- beautiful, with a possibility of electrocution.

Needless to say, rather than easing my way into WordPress, I immediately slapped in four plugins and pulled an Edward Scissorhands on the default template. The plug-ins didn’t crash in horrific fashion or throw exceptions, which is always a good sign of a mature application. At the same time, the PHP templates were pleasantly easy to modify due to the intuitive organization and readability of code. No electrocution after all – most excellent.

The only misstep was Akismet, which was temporarily giving problems about not having an API key even after I created an account. Apparently, it was just an issue of waiting for the key to propagate on the server, as the key worked fine an hour later.

So, for any coders or business types out there that are looking for blogging software or a blog platform to use- for what it’s worth, WordPress has my vote.

Tips to Improve Your Webpage Load Times

Categories: news,seattle — Tags: , , — Posted by: Grant @ : 3:38 pm

It’s a good news day, as the Chef Seattle servers have been upgraded! Previously operating on the equivalent of a tall decaf, we are now jittering at double-shot venti levels with dedicated web, database and firewall servers. Combined with our improved back-end and front-end coding, our site should be rockin’ fast now.

For those web developers who wonder about the effect of load times, studies show [akamai.com] that the average visitor will leave a retail website if it doesn’t load in under four seconds. That’s quite a harsh penalty in absolute terms, but in the context of the web three seconds is an eternity. The good news is that most web pages do meet the three second rule. The bad news is that four seconds is the absolute pain threshold and that web developers can always do better.

So, for the casual webmaster out there, here’s a few quick PHP and mysql tips from the development side of Coffee.net on how to help beat that four second (and hopefully one second) rule:

  1. In your scripts, try to either stay in PHP or stay out of PHP for as long as possible. Constantly jumping in and out of PHP is inefficient and will cause forking unless you use a module like FastCGI.

    Good: echo ‘[html][h1]‘.$header.’[/h1][/html]‘;

    Bad: [html][h1][?php echo $header; ?][/h1][/html]

  2. Use single quotes instead of double quotes in your echo statements. Double quotes are processed for variables while single quotes are not. It adds a little time to your coding, but leads to cleaner and faster code

    Good: echo ‘You are visitor’. $visitor;

    Bad: echo “You are visitor $visitor”;

  3. When hitting your database, try to combine queries if possible, rather than constantly going back. Your sql server does not take kindly to taking request after request in a row and performs much better when given a giant query over a multiple small ones.

    Good: $result = mysql_query(‘SELECT `firstname` FROM tblPayroll WHERE `lastname` = \’clinton\’ OR `lastname` = \’obama’\ OR `lastname` = \’mccain\’ OR …’)

    Bad: foreach ($candidates as $foo) { $result = mysql_query(‘SELECT `firstname` FROM tblPayroll WHERE `lastname` = \”.$foo.’\'); }

  4. Use mysql_fetch_row or mysql_fetch_assoc rather than mysql_result. The speed is quite superior in large datasets, as it fetches an index and then moves the key up, rather than n-searching for a row number.

    Good: while ($vars = mysql_fetch_assoc($result)) { echo $vars['firstname']; }

    Bad: for ($i = 0; $i < mysql_num_rows($result); $i++) { echo mysql_query($result, $i, ‘firstname’); }

  5. Set proper indexes on your sql tables. Indexes help your database determine where a row is located in your table, rather than iterating over every single row looking for that specific item. S you have column ‘lastname’ and it has the values ‘clinton’, ‘obama’, ‘mccain’, ‘paul’ and ‘romney’ in that order. If you want to lookup ‘paul’, your database will first match against ‘clinton’, then ‘obama’, then ‘mccain’ and finally find ‘paul’ at the 4th row. Not horrible, until your database grows to a thousands of rows and now you’ve got 4,000 rows to search before finding your guy. By indexing the column, your database will sort the names alphabetically and assign values to each rows, such as 1-clinton, 2-mccain, 3-obama, 4-paul, 5-romney. Now when it looks for ‘paul’, it simply jumps to row 4 directly and bam, you’re done.

These are just a few quick tips on coding that address some of the major bottlenecks that most coders will encounter. Obviously, there are other ways to seriously beef up your load speed like (duh) upgrading to a dedicated server, caching, pre-compiling your php scripts, using compression and using heap (memory) tables for read-only operations. But if you know about these, then you probably already know all the basic tips anyways :)

Before we go, we want to thank the guys at Wowrack.com (Ed, Budi) for helping with our server setup. Wowrack is based out of the Westin Building, smack in the center of Seattle. We originally hosted our site with a very reputable facility on the East coast, but it made a lot more sense once we were out of the development cycle to bring our servers closer to home. After all, it just doesn’t make a lot of sense for internet traffic to travel 3,000 miles to access a website about the city you live in, right?

Cheers to our new servers!

Home | About Us | Seattle Restaurants | Food Articles | Blog | Friends | Charity | Advertising | Contact Us
Blogging platform by WordPress
28 queries. 0.149 seconds.