Skip to main content
Web Design

Setting up a cookieless host

By October 30, 2019June 25th, 2024No 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

Newsletter on mobile and desktopWeb Design
August 27, 2024

Legal Landscape of Newsletters: Key Considerations for Compliance

Creating and distributing newsletters can be an effective way to engage with your audience, share updates, and promote your products or services. However, there are legal considerations to keep in…
Digital ExperiencesShopifyWeb DesignWordpress
June 27, 2024

Lincoln Collective Design & Development Studio

Introduction In the digital age, a strong online presence is crucial for the success of small businesses and startups. At Lincoln Collective, we understand the unique challenges these businesses face…
UX/UIWeb Design
June 13, 2024

Top 5 Web Design Trends to Boost Your Online Presence in 2024

Introduction In the fast-evolving digital landscape, staying updated with the latest web design trends is crucial for maintaining a competitive edge. An up-to-date and visually appealing website can significantly enhance…
DesignGraphic Design
June 13, 2024

How to Effectively Rebrand Your Business: A Step-by-Step Guide

Introduction In the fast-paced world of business, maintaining a strong and relevant brand is crucial for success. Rebranding can breathe new life into your business, helping you stay competitive and…
DesignGraphic Design
June 12, 2024

The Importance of Typography in Design

Introduction Typography is a fundamental aspect of design that often goes unnoticed but plays a critical role in how a message is conveyed and perceived. From readability to brand identity,…
Graphic DesignGraphic Design
June 12, 2024

The ROI of Investing in Quality Graphic Design

Introduction In today’s competitive market, the visual representation of your business can make or break your brand. Quality graphic design plays a pivotal role in building a strong brand identity,…
Start a project