WordPress Optimization Part 2
Few days ago I wrote a post on optimizing wordpress. However, the tips were on onpage optimization. I will be talking about server side optimization for your wordpress blog, which is serving static content from a cookieless domain and parallelize downloads across hostnames.
These two are the most important factor in Google Pagespeed and YSlow. These also affect search engine ranking as Google and Yahoo takes the page load time into account.
1. Serving static content from a cookieless domain
You can serve your static images and javascript filles from a cookieless domain, which will reduce the pageload time. You can either use a separate top-level domain or just use a sub domain like the one I am doing for itsabhik.com.
- Set your cookie domain: You need to set your cookie domain first. This is very easy in wordpress.
Open your wp-config.php file in a text editor and add the following line just after the opening php tag (<?php).define('COOKIE_DOMAIN', 'www.mydomain.com');This will serve the cookie only for the www subdomain keeping all subdomains cookie free. For example, images.mydomain.com or static.mydomain.com.
- Create the Subdomains: You now have to create subdomains for serving the static contents. If you are using cPanel, then it is easy to create subdomains and point them to the folder containing the static contents. Login to your cPanel and click on the “Subdomains” under “Domains” bar. Now, create a subdomain called images and choose your theme’s image folder as the document root. Similarly, create a subdomain domain for javascript files and point it to the javascript folder of your theme.

- Edit your Theme Files: You now have to edit your theme files to tell your server to serve the contents from the newly created sub domains. Before proceeding, make sure to back up your blog in case anything goes wrong. Download your theme folder and open the CSS Stylesheet file in text editor. I recommend Notepad++ as it has a search and replace feature.
To replace the image path, search for “background:url(‘images/image.gif’);” and replace the “images/image.gif” with the full URL of your subdomain. If your subdomain is images, it will look like “background:url(‘http://images.mydomain.com/image.gif’);”. Replace all other background calls, save the css file and upload it overwriting the existing one.
Similarly, search and find php files for javascript calls and replace the url with the subdomain url. Upload the edited files overwriting the existing files.
Now clear your browser cache and cookies and reload your blog. You should see a huge increase in performance. Check Pagespeed or YSlow (if you are using Firefox) if this is working.
Remember, some visitor tracking scripts like Google Analytics and Statcounter may still send cookies to your subdomains. You need to edit the analytic code to stop those sending cookies to subdomains.
2. Parallelize downloads across hostnames
Parallelizing downloads across hostnames means using different hostnames to serve contents. This reduces the http calls to one hostname (i.e, your main domain) and reduces the page load time.
Since we are using 3 hostnames to serve the static contents (one for images, one for javascripts and the third is your main domain), we need not do anything more to parallelize downloads across hostnames. However, you can use few more subdomains for static content and the performance will increase.
Always remember, you should take a full backup of your blog (including files and mysql database) before going for any of the modification. This comes handy if you messed up with the settings or edits.











you created wrong sub-domain configration
wen you create cookieless domain it should point real site root
not the sub domain root
ex:/public_html
not:/public_html/imgs