Serve Static Content from a Cookie Free Domain
80-90% of the end-user response time is spent downloading all the components in the page: images, stylesheets, scripts, Flash, etc. As such, serving the static content from the cookie free domain is a good practice for all websites, where even a little extra time to load something can mean long lag times. WordPress happens to have a provision to enable this feature.
You need to set below two constants in yourfile.
define("WP_CONTENT_URL", ""); define("COOKIE_DOMAIN", " ");
Please make sure that you have used
"bloginfo ('template _directory')"to load your static content in theme files.
After this, Please make sure that you have used
"bloginfo('template_directory')" function to load your static content in theme files.
Set an Expire Header for the Static Content
Setting the expire header to far future date will instruct your web browser to cache and serve those cached content until that expire date. You can set the expire header using some easy edits to your .htaccess file. I recommended to use the code provided by the HTML 5 Boiler Plate, You can review the same code below:
Declare a Constant for Most Used WordPress Database Values (Updated!)
This can be useful for the theme developer to reduce the number of database query on database. As a being WordPress theme developer we need to use some WordPress function which we need to use most frequently and more than once in a page.
For example, to get the url of the home page we generally use the get_option(‘home’);. This function actually perform the query on database and get the value we want. As we know this will be same for all cases and we might need this value on various places.
So what to do for this situation?
I used to create a new constant variable in wp-config.php like below:
After declaring this constant you need to use this constant instead of the get_option(‘home’) or similar function. So this will reduce the number query in the page. You can define constants for template directory too.
Optimize Your Database
There are a few plugins available which can take responsibility to optimize and maintain the WordPress database. I’ll list just a few below, but if you search the WordPress Plugin Directory, you should be able to find quite a few more:
Caching is the Key to Success
Caching is the most important factor for the optimize the high traffic site. WordPress has various good plugins available which serve this purpose. These plugins will generally create .html files for each post and page, and it will serve these html files instead of making the database queries every time.
We have some good plugins for caching in the WordPress.
Above plugins generate the HTML files for the each posts and pages and serves it, but we have one plugin which cache the database query result.
Use a CDN for High Traffic Websites
Using a CDN (Content delivery network) is the better option for the high traffic site. CDN is the Content Delivery Network of the optimized servers all over the world. These servers works together to server your content via number of servers.
Most of the CDN’s out there right now are paid and can be very costly. We have only one CDN which is free 🙂
Compress and Combine JS and CSS Files
Compressing the JS and CSS will give you a good improvement in site loading time. As compressing the JS and CSS files will decrease your overall page size.
Another good points to keep in mind is to combine CSS and JS files. Combining the multiple files into single file will reduce the number of HTTP request to your web server.
Alternatively you can use WordPress wp minify plugin for combining various JS and CSS files into one file.
Like compressing CSS and JS files its also good to compress the images of your WordPress site. We have plugin which uses the API of theand provide the compressed images for your WordPress site.
Use of CSS Sprite is also beneficial in case of reducing the number of HTTP request.
Compress Your Static Content with gZip
Compressing the static contents with gZip compression will drastically change your site loading time. Its a good practice for general web development too. Again I will go with the HTML 5 Boiler Plate for this trick.
You just need to place below code in your htaccess file:
eTags are also used for caching purpose, but if you have set a expire headers for the static contents then its good to disable the eTags functionality. Let’s see how to disable the eTag using .htaccess file.
You need to place one line in your .htaccess file to disable the eTag.
To know more about the eTag, you can visit this link.