Skip to main content
Web Design

Setting up a cookieless host

By October 30, 2019October 20th, 2022No Comments
cookieless host

When a browser makes a request for static files on your page such as an image, CSS file etc there is no need for it to add cookies with it, which results in sending additional traffic to the server. And additional traffic means more waiting time for the response by the server.

You can try these steps if you think your server response time is not good.

So the advantage of setting up a cookieless domain is that you can separate the content that doesn’t require cookies from the content that requires it. Using the cookieless domain will deduct unnecessary network traffic and eventually increase the server response time + the page performance.

How to set up a cookieless domain for a WordPress site

There are a couple of ways to set up a cookieless domain. You can read all the procedures on this page. However, in this article, I will mention how to set it up manually for a WordPress website.

Before starting the process one thing you need to remember is that if you set cookies on the top-level domain ( yourdomain.com) all the subdomains will also include the cookies in them. Because, as it sets on the primary domain its childs are going to have the DNA for sure. So in this case, you are recommended to use a separate domain to deliver static content. It’s a better idea if you register a new domain and configure the webserver to serve static resources from the new address. You will completely prevent any cookies to be set in the new domain.

Instead, you can also set two different domains. One which includes cookies and one which doesn’t set cookies. In such a case, will set cookies on a www subdomain (www.yourdomain.com) and separately host your static files from another subdomain like (static.yourdomain.com). This static domain will no longer send cookies with your static files of a page.

Cookieless domain in WordPress.

1. Create a subdomain

Go to your Cpanel and create a subdomain like static.yourdomain.com. From this subdomain, you will serve or host all the static files.

Go to subdomains > make sure you are on the page ” create subdomain” > place “static” on the subdomain box > let domain box stay in default name > click on create.

2. Point subdomain to wp-content

Now point the newly created subdomain to the “/wp-content” directory of the WordPress installation folder.

To do it again go to your subdomains and edit the settings by clicking on the edit icon next to your new static domain.

It will take you to the document root settings where you need to update the root address from “public_html/static” to “public_html/wp-content”.

3. Update your wp-config file

Go to the file manager using Cpanel or FTP client and edit the wp-config file. Make sure the following code is available or added inside the file.


**Remember to correct your domain names

4. Direct URL to a new subdomain

Before taking this step make sure you back up your database, in case of any kind of misconfiguration. Better to practice with the demo site before applying live the version. I do not take any responsibility for further loss of data or the website is down.

Now you need to run an SQL query on a database table. Go to PHPMyAdmin > select your wp database > go to SQL tab and paste the following code in the command box.

UPDATE wp_posts SET post_content = REPLACE(post_content,’www.yourwebsite.com/wp-content/’,’static.yourwebsite.com/’)

This will make sure all the post URLs are directed to the new subdomain.

Recent Posts

Web Design
October 13, 2022

Internet Explorer Support

We usually get asked why we don't support Internet Explorer and the main reason behind this is that only 1.8% of internet users are IE users and it is very…
Importance of EcommerceShopifyWeb DesignWordpress
April 11, 2020

Importance of eCommerce

With the increasing need for eCommerce, every businessman is looking to have an online store where they can sell their range of products and services. There are so many benefits…
ArtGraphic DesignVisual ArtsWeb Design
April 9, 2020

Selling Your Work as Merchandise

Selling Your Work as Merchandise: How to Get Started There are many ways to make money as a designer and a creative professional. The internet certainly makes getting clients from…
DesignGraphic Design
March 12, 2020

Choosing the correct font for your next project

The fonts you use can have a surprising impact on how your designs are perceived. The font or typeface can affect how often your content is read and how well…