How to Use Cookie-Free Domains

1. Quick read

When you check your site in the speed test tool generally you see the recommendation or warnings in GTmetrix tool ‘Use- Cookie free domain’ . Aren’t you aware about this term? You should have many more questions on this…like why should you use cookie-free domains? How to use cookie- free domain? etc…Don’t worry I will explain in detail in this blog so that you can be aware about this term and you get the importance of this in your shopify site speed optimization.

2. What are HTTP cookies?

HTTP cookies help to send the piece of data from a specific webpage or website.These small data are stored on the user’s system by the user’s web browser when he is browsing the web page. In other words, cookies are a small part of information sent from the web server to the user’s browser. They are later sent back to the server to notify it about the user’s previous activity like login authentication or items added to the shopping cart in the previous user session.
Cookies collect data to your website such as shopping cart items, pages you visited, etc. Using cookies to your website is valuable as they provide many benefits and better user experience on your site. It is helpful to determine whether or not a user is logged in and with which account. When users browse the website subsequently then the browser sends the cookie to the website’s server and provides the information that was set at last request. So cookies are useful for session management, tracking the users activity, etc.

What is a cookie-free domain?

Cookies are used for tracking, cart item, session (login), etc. When a user requests a web page URL (domain) then it sends back to the requested user data along with some response headers. And the responses headers might tell the browsers to set the cookie.
Cookie-free domain is a domain which does not send a command to the user’s browser to store cookies from the website. As our website contains some static content such as images, JS and CSS files those don’t change often. That’s why they don’t need to be set by cookies, as there is no user interaction with these resources.
By doing this cookie-free domain configuration you can decrease the size of the total request made by the user’s browser to our server. If it helps to reduce the server requests then definitely it will improve your site speed.

3. How cookie free domain work:

When the users requests static images from the web server and sends cookies with the requests, the server ignores the cookie and these cookies are unnecessary traffic and considered a performance hit since they have no benefit but can make HTTP requests and take longer to complete. A solution is to use a subdomain to host only the static content or your website. Doing this way subdomain will become cookie free since your cookies are set on the main website.
There are some advantages using Cookie-free domain:
  • Less network traffic
  • Decreased loading times on static content

4. Why use cookie-free domains?

As we see cookies are very useful in some cases, but to deliver static content, they can hit the performance. As when a browser makes a request for a static content such as images, CSS, JS files, there is no need for it to also send a cookie to the server. Due to this network traffic gets increased and to deliver static content to the user there is no need to set cookies for these.
By using a cookie-free domain you are able to separate the content that doesn’t require cookies from the content that does. Doing this your site’s performance will improve by eliminating unneeded network traffic.

5. How to use cookie-free domains

We are aware about Cookies and its importance for your site. Now it’s time to set up cookie-free domains for your website
There are some ways to configure a cookie-free domain. Using a seperate domain name, Set up a CDN, etc.

Configure a cookie-free domain separately

Here, you will create a completely separate domain name for your website to host all the static contents without any cookie command to the browsers.
If you don’t have any domain then first you should purchase a domain, skip this purchasing domain if you have purchased already. You can create a sub-domain in case you don’t want to buy a new one. If you prefer to use sub-domain, recommend to use a static prefix so anyone can understand by looking at the name.

Use of CDN to deliver static content

CDN is also helpful to deliver static content. KeyCDN provides the ability to ignore cookies through the Cache Cookies setting. Using a CDN you can solve the cookie-free domain problem. There are several CDN are available, most of the CDN has the ability to ignore cookies and strip cookies which helps to completely prevent the browsers from receiving the Cookie response header. If both settings are enabled, your static content is being delivered via the closest CDN edge server and cookies are automatically stripped ensuring there is no additional cookie latency. This is an easy alternative from moving and configuring your site to deliver static contents from a separate subdomain. With a CDN that strips cookies, you can easily deliver content without cookies.

Latest Posts

Leave A Comment