Posts Tagged ‘mysql database’

Simple tricks to speed up your WordPress website.

WordPress is a great tool but for those of us on shared hosting it’s important that as our web traffic increases we look at ways to decrease the amount of stress our sites put on the web server. I found a couple of wonderful suggestions on Lorelle’s website and I’ve added a few of my own.

There’s a couple of reasons for this, first we want to make sure our web pages load as quickly as possible but as importantly we want to ensure our website stays online. There are countless stories on the internet about websites that suddenly found themselves very popular and struggled to keep up with the traffic, only to have their account temporarily shut down by the hosting company.

WordPress is written in PHP and uses a MySQL database to serve up content. This is great except the content on your website doesn’t change all that often so why are you dynamically generating it for each visitor? Instead of rebuilding the xHTML for each visit, why not serve them a previously saved version? We call this caching a website and it can be done with the wp-cache plugin from Ricardo Galli Granada.

So the first step to increased speed of your WordPress website is to download and install the WP-Cache plugin. It allows you to set how many seconds between page caching as well as if any specific files should never be cached. Very handy. You should also make sure you’re on a reliable web host who can handle the traffic.

Diggproof & Speed up Your Wordpress Blog has a great and often overlooked suggestion. Upgrade your WordPress blog. This might sound silly but generally speaking the latest code releases for WordPress are stable and optimized, so taking a little bit of time to upgrade your site during each release is a solid idea.

Unused plugins can kill performance so before you go installing and forgetting about your plugins, make a habit of deleting unused plugins. Some people might assume deactivating them is good enough but personally I prefer to delete them.

Using a tool such as phpMyAdmin take time once a week to optimize your MySQL tables. If you don’t have access to phpMyAdmin, execute the following SQL statement from your command line to make sure your tables are in the best shape possible:

OPTIMIZE TABLE `wp_comments`, `wp_links` , `wp_options` , `wp_postmeta` , `wp_posts` , `wp_ratings` , `wp_terms` , `wp_term_relationships` , `wp_term_taxonomy` , `wp_usermeta` , `wp_users` , `wp_wpsb_users`

Arne has some great suggestions for MySQL Query Cache and PHP Compiler Cache options, they’re pretty technical but well worth it if your running into significant server speed issues. If you’re technical, give this article on how to configure Apache a read as well, it will help you optimize your whole site.

Paul Stamatiou makes a great point by writing “Every HTTP request, or loading each item on your website, has an average round-trip latency of 0.2 seconds. So if your site is loading 20 items, regardless of whether they are stylesheets, images or scripts, that equates to 4 seconds in latency alone“. So, take a good long look at your theme and determine what you really need in there. I saved a ton of time per page load by stripping out over 20 JavaScript calls and replacing them with PHP scripts which are cached once every five minutes. I also combined all my CSS files into a single file which decreased the number of HTTP requests my server had to take. Paul also have a great article on Compressing CSS with PHP that you should read if you still need to speed up your site more.

There’s another great suggestion from WPCandy that I’m extremely reluctant to do, but I know they’re right. First, use shorthand CSS so:

#commentarea li {
margin-top: 10px;
margin-bottom: 10px;
}

should become:

#commentarea li {
margin: 10px 0px 10px 0px;
}

You should also decrease whitespace (that’s the empty space between tags), sure it makes it look better but it also takes up bandwidth.

Finally, decrease your overall database calls. WordPress gives us all sorts of great functions in our templates but really do you need to call the website name from your database? The simple answer is no, so let’s decrease the over all number of MySQL queries by optimizing our templates. Replacing with your title for example will help decrease the server load.

I hope this helps, if you have any other suggestions for how to optimize WordPress and speed up the site please let me know.

Federal Government of Canada

Over the past few years, I’ve had the pleasure of working with several government departments to provide web development and programming services. Below are a few samples of key projects.

nrcan sbml 150x150 Federal Government of Canada imageWritten in PHP, the SBML web interface allows employees of Natural Resources Canada (NRCAN) to search a FileMaker Pro based database using an XML based data conversion method. The tool is housed as part of the national internet and allows the staff to find research papers from across the country.

nrcan knowledgeassetinventory 150x150 Federal Government of Canada imageAnother PHP powered web search tool written for Natural Resources Canada (NRCAN), the tool allows staff throughout the country to search for knowledge assets, photos, illustrations and technical documents. The web tool uses PHP to connect to a FileMaker Pro database server through an XML interface. As with all government projects, this one uses strict xHTML and CSS to ensure compatibility.
nrcan briefingnotes 150x150 Federal Government of Canada imageDeveloped for the Minister of Natural Resources, the Briefing Notes database was created to allow easy access and search tools for sensitive materials throughout the organization. Each document was automatically indexed and uploaded to a FileMaker Pro database which in turn linked to web based search tool. Included in the tool was document versioning control to track multiple versions of the same document and commenting, so additional feedback could be provided.
agriculture pool 150x150 Federal Government of Canada imageThe POOL database was created for the Central Experimental Farm of Agriculture and AgriFood Canada to provide genetic oat data for scientists throughout Canada. Using PHP with a MySQL database, the oat data provided scientists with the ability to link related research and increase the speed materials became available to other research scientists.