Thank you for choosing prositeweb, your web development agency in Montreal. Please call us at +1 (514) 548-2165 if you need immediate support.
In this article, we explain how to create a cookie free domain: –
If you want any further information on the topic or want to create your own website, contact us today!
A cookie free domain is essential for improving website performance. Indeed, To enhance the website’s performance, there is a recommendation from GTmetrix regarding the cookieless domain. What is that? How to implement it on WordPress? These questions will be the focus of this article. For example, we are going to show you an easy way to use it to speed up your website without using a plugin. Even though the steps are easy to understand, you will need some basic PHP or copy-paste skills.
Before discussing a cookieless domain, it is important to define a cookie.
A cookie in web jargon is a piece of information that websites or applications save in your web browser. This is generally intended to facilitate the management of your information or preferences. For example, if you visit a car sales website. The website you visited may put data in your browser to subsequently make suggestions to you about your preferences. This is quite common in the web world, and several solutions would work with quite a limitation if there were no cookies.
Cookies usually have a maximum size of 4 KB per domain name. It is important to note that as a user, you can block or limit cookies on your web browser.
As cookies accumulate in your browser, it affects how long you can take to navigate a website. This is why you will notice that a website takes longer to display information after a while compared to your first visit.
The information about your photos or video is generally static (changes little). Therefore, having a domain name that does not retain cookies when serving images and other static files can help improve performance. A cookieless domain name is a domain you set up for your photos, videos, and other code like CSS and JS.
To implement it on your WordPress website, you need to follow three steps:
If your domain name is domain.com, for example, you can create a subdomain called static.domain.com that will serve as your cookieless domain.
The steps to follow may vary depending on your web server.
Before creating a subdomain, you must make sure that your domain offers this possibility. Indeed, in your DNS record (the server where you manage your domain name settings), you must add a CNAME line similar to what you see below. It would therefore be important to make sure that your domain name is active after its creation before making the configurations.
For this article, we will base our example on the cPanel. In your cPanel dashboard, follow these steps:
Open the WordPress configuration file, located under the installation directory and paste the following code:
<?php /* Edit wp-config.php and add this code. replace prositeweb.ca by your own code */ define("WP_CONTENT_URL", "https://static.prositeweb.ca"); define("COOKIE_DOMAIN", "https://www.prositeweb.ca"); ?>
To update the database, you need to check your tables prefix in your wp-config.php file. Usually the prefix is wp_. However, it is possible to change when creating a website. Once you find the prefix. You will need to connect to your database server to make the request.
This step involves changing the links to the images to point them to the new server. Below is an example request.
UPDATE wp_posts SET post_content = REPLACE(post_content,'www.yourwebsite.com/wp-content/','static.yourwebsite.com/');
In the query above, you need to replace yourwebsite.com code > your domain name. Otherwise, if your database prefix differs from wp_, replace wp_posts code> with the correct prefix.
The creation process could be similar to the case of WordPress. You would simply have to create the subdomain and then replace the links of the photos and other static information to point them to the new domain.
If you follow these steps, you will notice the performance improvement in your analysis report.
If you followed this article correctly, you should have successfully created your cookieless domain on your WordPress site. Feel free to check out their website for different related content. If you need help optimizing the performance of your website, you can contact us through our contact form.
Contact us if you are looking for a Montreal-based web agency capable of supporting you in Backend and Frontend development.