Wordpress

PHP Tweaks to speed up your WordPress website

WordPress is the most preferred Blogging and CMS platform.Though WordPress offers developers a wide opportunity to customise their site,the issue that many face is the high CPU usage and slow load of WordPress site.There are many ways followed to tackle such.But it can be minimized to a certain extent by simple PHP tweaks in the WordPress core files.Some simple and effective ways are discussed here.

Configuring config.php

Do you know that everytime a wordpress page is loaded DB queries are made to fetch the default URL of the website,Home URL,Template URL and Stylesheet URL?By defining those in the config.php file DB calls for such can be avoided.This in turn saves the Query time and a bit of  CPU usage.Just by adding the following lines of code you can avoid unnessasary DB calls on every page load,

define('WP_HOME', 'http://www.technostreak.com');
define('WP_SITEURL', 'http://www.technostreak.com');
define('TEMPLATEPATH', '/full-path-to-wordpress-root/wp-content/themes/abc');
define('STYLESHEETPATH', '/full-path-to-wordpress-root/wp-content/themes/abc');

WordPress Security keys,Your DB is accessed every time to obtain these.Having it pre-defined in the config.php will reduce the SQL process and DB call.Get your WordPress security code from here and paste it in config.php it looks something like this…

define(‘AUTH_KEY’, ‘xxx’);
define(‘SECURE_AUTH_KEY’, ‘xxx’);
define(‘LOGGED_IN_KEY’, ‘xxx’);
define(‘NONCE_KEY’, ‘xxx’);

Another two line code is optional,in which the first increases the wordpress memory limit to 64M and the secon increases the default autosave time from 60 to 300 seconds.

define('WP_MEMORY_LIMIT', '64M');
define( 'AUTOSAVE_INTERVAL', 300 );

Disabling the post revision.This will reduce number of rows in WordPress post table == faster page finding and loading.Use this if you want.

define(‘WP_POST_REVISIONS’, false);

Boosting Speed by tweaking header.php

You may use caching plugins to speed up your page load.But a small snippet too could do a effective job.If your web server supports zlib file compression,you may add the below snippet at the top of your theme’s header.php file.

<?php
ini_set('zlib.output_compression', 'On');
ini_set('zlib.output_compression_level', '1');
?>

Hope the methods listed will be of some use to you if you use WordPress.Use the mentioned methods at your own risk.If something goes wrong,remove the code you just added to revert back.Leave your valuable comments about these tweaks.

About the Author

Tharun is a bit attracted towards computers and stuff.He loves to blog,share and know more about computers and technologies.He shares what he feels is something good on this site...Stay connected.
Tharun is on: Facebook , Google+ , Twitter

1 comments
Flyers
Flyers

the cooperation of the PHP towards the wordpress is really a great work in the need of increasing the field possibility,
Thanks!