Its better to serve the static contents from separate cookie free domain. Which speed up your website. This is because browser will consider both as a separate domain.
The simplest way to create a cookie free domain in create a sub domain. By default what ever cookies created on main domain will be shared on sub domain also.
But in wordpress we can define that only for which domain it should store the cookies. So it will not get shared on subdomain.
Here are the steps for that:
First create a subdoamin. like cdn.xyz.com, images.xyz.com, i generally use static.xyz.com
Now point this domain to the wp-content directory of the wordpress.
Aftre doing this you need to edit the wp-config.php file which is located at the root of the wordpress.
You need to add below code in your wp-config.php file.
Note: Please make sure that you have used “bloginfo(‘template_directory’)” to load your static content in theme files.
Please check here for more details about cookie free sub domain.
Avinash Zala is leading various projects which deals with the various technology involved with the web. A combination of perfect technical and management skills. Avinash would like to chat with you and convert your imagination into the working system. You can get in touch with him on Facebook and Twitter.
View all posts by: Avinash