There are different methods you can use to set up a cookie-free domain. Simply follow these steps to use a cookie-free domain on your WordPress website. Create a Subdomain A cookie-free subdomain has to be created to deliver the static content. That’s because using the main domain will make the cookies be set in all your subdomains
- Log into the cPanel and select Subdomains.
- Create a new subdomain(website.testingsite.com)
- Point the subdomain to the WordPress wp-content directory in the document’s root field
- Navigate to the File Manager in cPanel and add the code below to the wp-config.php file.
define(“COOKIE_DOMAIN”, “www.testingsite.com”); (Replace the links to reflect your webpage’s URLs).
- Find your WordPress database in your wp-config.php file
- Once you have it handy, go to phpMyAdmin -> SQL
- Redirect all posts to the new domain by running the command below in the SQL database.
UPDATE wp_posts SET post_content =
REPLACE(post_content,‘www.testingsite.com/wp-content/’,‘website.testingsite.com/‘)
The subdomain website.testingsite.com will deliver all static content without cookies.
- Create an account on KeyCDN website. You can try out a free trial for a new account or upgrade to a premium account
- Navigate to the WordPress repository and install the CDN enabler plugin
- Inside the KeyCDN dashboard, create a new Pull-Zone and save.
- Copy and paste the CDN URL inside your WordPress plugin.
- Once your setup is completed, clear your website cache and wait for it to take effect.
- Check the test results on GTmetrix again, you will notice an improvement.
- Log into your WordPress dashboard
- Go to plugins
- Install the plugin and then activate
- Select wp2static from the left bar within the WP dashboard
- Set up the settings inside the “Deploy static website” tab.
- Once the export process is done, visit the URL that you have set during the configuration. (https://testingsite.com/website). The warning to use cookie-free domains will not display in the GTmetrix report again.
Using a different domain to serve static content reduces unnecessary cookie traffic on the server.
Cookie-free domains do not require users’ browsers to store cookies for them which improves website performance and increases loading speed, especially for static content. Cookie-free domains are an essential part of website optimization efforts, We hope you have learnt how to set up a cookie-free domain on WordPress to improve your traffic, SEO, and user experience.