If you go to GTMetrix now to test the performance of your WordPress websites, you will most likely get a “serve static content from a cookieless domain” warning.
The thing is, there is absolutely no need to serve static content with cookies. Doing so will add extra workload to your web server, thus reducing the load speed and performance of your website. You definitely don’t want that to happen.
In this article, we will explain what a cookieless domain is. Also, you will get to learn how to solve this cookieless domain warning issue.
What is a Cookieless Domain?
First off, what’s a cookie? When you visit a website for the first time, your browser will make HTTP requests to the webserver where the website’s files are stored. In return, the webserver will send over the files, along with cookies which will be stored on your machine.
Your personal details such as browsing preference, login ID, location, etc. may be stored in these cookies. The next time you visit the website, all the browser needs to do is to make reference to the cookie, thus cutting downloading time and saving you extra work.
A cookieless domain, as the name implies, are domains that don’t serve cookies. If you were to visit a website on a cookieless domain, cookies won’t be sent to your browser.
Why Set Up a Cookieless Domain?
The thing is, it takes time to upload cookies from a domain. As such, cutting them off, as much as possible, will help improve the loading speed of a website.
As such, adding cookies to static content makes little sense.
So, it’s best to serve static content from a cookieless domain so as to make the website load faster.
How to Fix Serve Static Content From a Cookieless Domain Warning
Migrating your website from HTTP to HTTPS, if done right, will help solve this problem. In this article, we explained how to do so.
The other two ways to solve this problem are:
- Using a Content Delivery Network (CDN)
- Setting up a sub-domain and then pointing it to your main domain.
Using a CDN
If you have the budget and are looking for a quick, easy way to solve this problem, sign up for a CDN service.
CDNs help make a website perform better by reducing the distance between a client and a server. What’s more, if you run your website through a CDN, cookies from the static resources will be ignored by your visitor’s browsers. That way, you don’t have to worry about cookie domain warnings.
All CDNs are not the same, mind you. For instance, if you used Cloudfare, you might still encounter these cookie errors. To this end, we recommend Key CDN.
To know more about CDNs, including their pricing, read our comparison guide.
Setting up a Subdomain in WordPress – Serve Static Content From a Cookieless Domain
Setting up a sub-domain and pointing it to your main domain will also help take care of this error.
Here are the required steps:
Log into your cPanel and navigate to the subdomain page. There, create a subdomain. The subdomain could look something like this: http://static.mywebsite.com
Use your website’s domain in place of “mywebsite.com”. Most host providers offer free subdomain registration. So confirm from yours if they do.
Configure your DNS records as well as CNAME of the newly created subdomain to point to your main domain.
To do this, in your cPanel navigate to DNS Zone Editor >> CNAME
In the domain NAME section, type in the subdomain, then in the CNAME section, type your website’s main domain
Finally, click Add a CNAME Record
Set the configured subdomain to point to your wp-content directory. To do this, connect to your website to an FTP service such as Filezilla. Open the public file directory, locate and open wp-config.php file. Copy and paste the following lines of code into it.
define("WP_CONTENT_URL", "http://static.domain.com"); define("COOKIE_DOMAIN", "domain.com");
Save the file and you are done.
Conclusion – Serve Static Content From a Cookieless Domain
If you have been seeing cookieless domain warnings while testing your website performance tools like Pingdom and GTmetrix, now you will see them no more.
We’ve shown you three ways to solve this problem, one of which is migrating your website from HTTP to HTTPS.
Should the problem still persist, do reach out to us. We’d love to help.
If you found this tutorial helpful, be kind enough to share.
- How To Easily Clean Up Your WordPress Database
- The Fastest WordPress Themes Of 2019
- WordPress Meta Description