why to Use cookie-free domains

How to set-up Cookie-Free Domains

What is cookie free domains? How to use Cookie-Free Domains?

A domain that serves no cookies is called cookie free domain. Cookie Free domains is a separate domain which will not serve cookie and boost up your website speed.You can create sub domain for serving a static content such as; HTML, CSS, Images, Java-Script, Icon file etc. So, when browser load content from the separate cookie free domain, it will not send cookie data and users don’t waste time and bandwidth transmitting cookies for them.

Why is Cookie-Free Domains Important?

When you use cookie-free domains on your website, you are able to separate the content that doesn’t require cookies from the content that does. This helps in improving your website’s performance by elimination unnecessary network traffic.

How to set up Cookie-Free Domains

If you set your cookies on a top-level domain (e.g. yourwebsite.com) you can create another subdomain (e.g. static.yourwebsite.com) to host all of your static files which will no longer result in any cookies being sent. The idea behind this is that all your static cookies will be now host in your subdomain.

Follow the simple steps below to set up cookie-free domains

1. Create a subdomain such as static.yourwebsite.com or cookie.yoursite.com
2. Point your new subdomain to the /wp-content directory of your WordPress installationHow to point

How to point sub-domain to the wp-content directory

a. Login to your cPanel
b. Click Subdomains

Use cookie-free domains

Use cookie-free domains : Click Subdomain

c. Click the Edit icon

How to Use cookie-free domains in wordpress

Click Edit Icon

d. Now, write /wp-content after the public_html (there should be no space)

Point subdomain to the wp-content directory

Point subdomain to the /wp-content directory

e. Click Change

3. Now, Open your wp-config.php file of WordPress and add the following line of code into it.

define("WP_CONTENT_URL", "http://static.yourwebsite.com"); 
define("COOKIE_DOMAIN", "www.yourwebsite.com");

Now test your site using : GTmetrix.com

Also Read : 3 best WordPress plugin to optimize and compress images

Sharing is caring!

Suanlian Tangpua
Follow him

Suanlian Tangpua

Suanlian Tangpua is a Graphic & Website Designer based in New Delhi. He loves photography, cooking and blogging. Feel free to contact him at [email protected]
Suanlian Tangpua
Follow him

5 Comments

  • Steve June 7, 2017 Reply

    Hello,

    I have been trying to set this up on my website https://focoseo.com and can not seem to get this to work.

    I created static.focoseo.com and set the document root to /public_html/wp-content

    I then added the following to my wp-config.php file:
    define(“WP_CONTENT_URL”, “https://static.focoseo.com”);
    define(“COOKIE_DOMAIN”, “www.focoseo.com”);

    I have tried several different variations and it’s still not showing me anything different when I run a site speed check.

    Any help would be greatly appreciated!

  • Hewata May 15, 2017 Reply

    Hi…

    Can you also give the same tips for Secure Site. Because it does not work for my site (https://www.hewata.com).

    My site use Let’s Encrypt SSL included in my cPanel which cover hewata.com http://www.hewata.com mail.hewata.com

    When I create static.hewata.com which is non secure site, it is not included in the certificate.

    Hope you can help.

    Thanks

  • Mimi April 12, 2017 Reply

    Hello Suanlian,
    I am not using wordpress. Can you show me what step to follow after creating the Subdomain?

    Thank you very much!
    Mimi

  • Enrico January 7, 2017 Reply

    Hi Suanlian!

    Finally a step by step guide! 😉

    But I need one more information: if I have more domains on my cpanel what I have to write on step d?

    public_html/wp-content or public_html/example.com/wp-content?

    Thank’s so much!

    • Suanlian Tangpua January 7, 2017 Reply

      Hi Enrico,

      Both works, it depends on the website root.

      For Eg, If your website root is wp-content you can used public_html/wp-content. But if your website is locate in wp-content/example.com you have to used public_html/example.com/wp-content

Leave a Reply