We test our webpages on speed testing tools to find out its overall performance score and possible errors. These tools let you know what things are fine on your page and where you need to improve to make the page perform better in terms of loading speed and SEO.
Popular tools like GTmetrix, Pingdom, Page-insight, Bitcatcha, etc first scan your page and then measure to provide a score based on the page speed, the number of elements it contains, requests made by the page to the server to retrieve those elements per unit time.
You will also receive the recommendations per page that basically says where you need to put the work to take your page to the next level. Here is an example report provided by GTmetrix for a particular webpage.

The GTmatrix grade in the test report is an assessment of the overall performance of your webpage that reflects how fast it loads for the user and it’s built quality to deliver recommended performance.
It also fats information from Google Lighthouse and displays assessment with custom GTMatrix edit.

On the other tab, you will see the web-vitals report which is a metric that represents whether your page is delivering the kind of user experience recommended by Google.
Under web vital, you will notice LCP which is the calculation of time taken for loading the largest element on a page to appear for a visitor. According to GTmatrix LCP of a page should remain under 1.2 seconds.
Other important measures such as total blocking time (TBT) I will tell you how much time is blocked by the script on your page during loading. The lower the value the better is your score.
![How To Setup Cookie-free Domain Properly [Solution] 1 web-vitals-of-gtmetrix](https://wpblogging.in/wp-content/uploads/2020/11/web-vitals-of-gtmetrix.png)
Below these scorecards, you will get the top issues and warnings detected by GTmatrix and their related recommendation to resolve them. These issues are organized in a hierarchy which you can follow step by step and improve your page performance.
As you can see in the image above, leverage browser caching is a common problem for most websites. Another most common warning that appears in GTmetrix is to configure cookie-free domains.
If you are also getting serve scaled images warning on GTmetrix, follow this tutorial.
In this post, we will particularly talk about what is a cookie-free domain? Why should you use cookie-free domains? and how to configure cookie-free domains?
Before you start; remember, it’s good to use cookies for security, analytics and other features, however if you notice the cookie size which is of few bytes won’t bring great impact on the performance.
The concept behind this approach is to reduce server latency by reducing the number of requests which can impact a little on your individual page performance as well as the primary domain.
Now you know why you should use a cookieless domain, it’s time to plan how would you set up a cookieless site! It might look difficult but it’s not when you understand the flow of the mechanism.
With that being said, let’s get into the tutorial part and try and get your cookie free domain
How to set cookie-free domains
There are a couple of ways to configure a cookie-free domain. Such as using a separate domain name, set up a CDN, and reconfiguring the WordPress site. So we will discuss these methods one by one.
1. Configure a cookie-free domain separately
In this way of setting up a cookie-free domain, you will take a separate domain name to host a cookie-less website. It will host all the static contents without any cookie command to the browsers.
So, first of all, you have to register for a top-level domain, if you already have a domain name then skip to the next step. Alternatively, you can create a subdomain to avoid acquiring a domain.
In the case of a sub-domain, use a static prefix for better naming convention and make it easily understandable. For example: www.static.wpblogging.in.
Remember If you use your root domain without the www version, like wpblogging.in then using the subdomain as the cookieless domain might not work.
Again, if you are using Adsense advertisements then a cookieless domain warning will always occur because your sub-domain is a part of your root domain and Adsense set cookies for every sub-domain under one verified domain name
Now follow these steps;
To be more specific, after setting up the cookieless domain, use your .htaccess file to configure your webserver to serve static contents without cookies.
You have to keep the .htaccess file in the root folder of your domain. If you don’t know how to find and edit the .htaccess file check this article. Inside the file, you have to add these lines given below, _
# Use Mod_deflate to compress static files SetOutputFilter DEFLATE # Speed up caching FileETag MTime Size # Expires ExpiresActive On ExpiresDefault "access plus 366 days" # Future Expires Headers Header set Expires "Sat, 27 Dec 2019 23:59:59 GMT"
After this, you need to upload all of your static contents (components of your site that don’t change) to the new static sub-domain (or domain).
These contents include CSS, ICOs, Javascript, text, and image files. This way you can create a standalone cookieless domain from where static contents of your original website will be served.
2. Use a CDN provider to ignore cookies
Another good way to solve the cookie-free domain is by using a CDN provider. 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.
Each CDN has different features and functions, some may suit your need while others might not benefit you in solving the warning to use cookie-free domains. And if you are currently using Cloudflare CDN then you may need to disable it because you can’t just allow cookie-free domains in Cloudflare, unless you upgrade to the enterprise plan.
They inject a cookie called “__cfduid“. Due to Cloudflare’s reverse proxy strategy, cookies are sent on static files too, which are unnecessary.
According to Cloudflare;
Enterprise customers may request to disable the _cfduid cookie by contacting Cloudflare Support, but Cloudflare’s ability to detect and mitigate the impact of malicious visitors to a Customer’s website will be significantly impacted. While some speed recommendations suggest eliminating cookies for static resources, the performance implications are minimal. - Cloudflare
If you use Cloudflare with a caching plugin, you can change it to another CDN provider to solve the problem.
KeyCDN is a great alternative if you are looking for hosting a cookie-free site. You can deploy keyCDN to your WordPress site with a CDN activator plugin. Just follow the steps below.
- Go to the official KeyCDN website and create an account. They charge about 0.04$/GB of traffic data after one month free trial period ends. Test their service and if you feel better then go for a premium account.
- Then install the CDN enabler plugin on your website from the WordPress repository.
- Create a new Pull-Zone inside the keyCDN dashboard and save it.

- Copy the CDN URL and paste inside your WordPress plugin.

![How To Setup Cookie-free Domain Properly [Solution] 2 paste-url-inside-CDN-enabler-Cookie-free Domains](https://wpblogging.in/wp-content/uploads/2019/07/paste-url-inside-CDN-enabler-1024x549.png)
- Once your setup is done, clear your website cache and wait a little time to take the effect.
On completion of your set up, you should see the improvement in the cookie-less domain warning on your website test result.
3. Re-configure your WordPress site
In this method, you will create a subdomain from where you will deliver your static file. Then you need to point your subdomain to the /wp-content directory of your current WordPress installation.
Those who use cPanel, you will need to update the document root field from public_html/static to public_html/wp-content.
(Set up your subdomain’s DNS record as a CNAME pointing to your root domain with the wp-config file. To do that point your subdomain (any) to your /wp-content directory simply by editing your wp-config.php file. Add the following codes into your wp-config file)
Now edit your WP-config to reflect the following,
define("WP_CONTENT_URL", "https://static.domain.com"); define("COOKIE_DOMAIN", "www.yourdomain.com");
Point to note: Replace your domain URL and domain name inside the code mentioned above. Example: https://static.google.com
Now, run the following command in your SQL database to ensure all post URLs are directed to the new subdomain:
UPDATE wp_posts SET post_content = REPLACE(post_content,'www.yourwebsite.com/wp-content/','static.yourwebsite.com/')
4. Use Cookie-Free Domains – WordPress Plugin
One more alternative method is to use a WP plugin called WP2static. You can easily install the plugin from the WordPress repository.

After installing the plugin activate it. Now go to the WP dashboard and select wp2static from the left menu. Configure the settings under the “Deploy static website” tab. Check out the image below.
![How To Setup Cookie-free Domain Properly [Solution] 3 use-cookie-free-domains-wp2static-configuration-1024x423](https://wpblogging.in/wp-content/uploads/2019/07/use-cookie-free-domains-wp2static-configuration-1024x423-1024x423.png)
Once the export process is done, visit the URL that you have set during the configuration. (https://yourdomain.com/static). Now check that URL in GTmetix. The warning to use cookie-free domains shouldn’t appear inside the report.
5. Try it with BunnyCDN
As I have mentioned above, CDN will help you serve cookieless content on-page, one great example is BunnyCDN.
BunnyCDN will make your task even easier as toggling a button. On the cache control panel, you need to activate disable cookies and you can see an immediate impact on your site.

Though, serving a cookie-free domain won’t improve your site performance by a lot still you will be able to achieve a better score on page testing tools like Pingdom & GTmetrix.
Need help with getting stuff done? Try Fiverr! You can find content writers for your website at a reasonable rate.
Similar articles:
How to Configure Async Javascript Plugin Settings?
I’m truly enjoying the design and layout of your site.
It’s very easy on the eyes which makes it much more enjoyable for me to come here and visit more often. Did you hire out a developer to create your theme? Exceptional work!
We also love this design.
It’s clean, easy to read and most importantly attractive. This theme is custom-built by us.
Thanks and keep visiting for more tutorials
I don’t normally comment but I gotta tell appreciate it for the post on this great
one :D.
Glad you find it useful 🙂
Have you ever considered about adding a little bit more than just your articles? I mean, what you say is fundamental and all. But just imagine if you added some great pictures or video clips to give your posts more, “pop”! Your content is excellent but with images and clips, this blog could undeniably be one of the greatest in its field. Great blog!|
Hey Dave, thanks.
This is a custom-built theme for this website.
I and my friend Ashish built this 7 months ago.
Hey I’ve been trying to use the said plugin WP2Static and trying as you said but when I tap on export an error pops up saying ‘Please set the base URL field to Valid URL i.e. mystaticsite.com
However the issue is that there’s no such visible field called base url.
Hi Prajwal.
The base URL is the destination URL. That means in which address(URL)your visitors will find the static site.
For that, you need to create a static subdomain from your hosting panel something like (static.yoursite.xyz)
Once created you can set it as base URL (destination URL)
Hope that works for you 🙂
I can’t get Option 3 to work. My subdomain is set up in DNS in Cloudflare as a CNAME to point to my root domain e.g. static is an alias for mydomain.com.
Then I add that line in my wp-config.php but the result is a mangled page.
Is there another step?
How does the content from wp-content get into the subdomain and does it matter if I use http://www.mydomain.com as opposed to just mydomain.com?
Pretty! This was an extremely wonderful article.
Thank you for providing these details.
Appreciate the recommendation. Will try it out.