1 / 7

Use Cookie-Free Domains for Website Fast Load

HTTP cookies are small pieces of data that are sent from a website and stored in your browser. While a user is viewing a website that uses cookies, the cookies collect data pertaining to your website activity such as preferences, shopping cart items, which pages you visited, etc. Cookies are very valuable to many websites as they facilitate better user experience and are key in performing certain functions such as determining whether or not a customer is logged in, and with which account.

100utils
Télécharger la présentation

Use Cookie-Free Domains for Website Fast Load

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Have you ever used online tools to check the performance of your website? You must have come across one of them in the past. For example, tools like Gtmetrix, Pingdom, and etc. analyze your entire website and display a report and tells you which parts are working fine and which parts need extra attention. Whilst using this tool, you may come across the Use cookie-free domain error. An HTTP cookie is data sent to user browsers by the web pages. This data will be stored in the browser while the user is browsing the website. In the next visit, the data will be sent to the server to remind user information. What is the cookie-free domain? How and why should we use the cookie-free domain in WordPress? In this PDF, we are going to discuss how to use the cookie-free domain in WordPress. What is Cookie-Free Domain? Before we talk about using cookie-free domains in WordPress, let us explain what exactly is the cookie-free domain. A cookie-free domain is a domain which doesn’t send a command to users’ browser to store cookies from the website. Usually, websites have static information, which may never change. Images, CSS files, JavaScript and etc. Because these files are usually the same and they remain unchanged, there is no need for the user’s browser to save their cookie. Thus, by making some changes to the domain, you can lower the requests sent to the server from the user. This has many advantages. This speed and performance can be used elsewhere rather than wasting on storing unnecessary cookies on the user’s browser. What is the main reason behind this? Well, the main reason is to increase the website’s performance. By lowering the cookie requests, your website will run smoothly and it can answer necessary requests faster. How to Use Cookie-Free Domain in WordPress? We now know what is cookie-free domain and why you should use it. Generally, using cookie-free domain has two advantages: 1. Reduces network traffic. 2. Reduces the time required to load static content. Reduce Loading Time for Static Content

  2. Now it’s time to learn how to use the cookie-free domain in WordPress. Configuring the cookie-free domain in WordPress may seem difficult. But it’s very easy if you follow the steps below. Much like other tutorials on our website, we would introduce multiple ways to use the cookie-free domain in WordPress. For example, using a CDN, or a separate domain. In this PDF, we are going to discuss viable solutions. Keep in mind, if your domain configuration is set to use cookies, all of the subdomains will use the same configuration. Therefore, to use the cookie-free domain you will need to use a separate domain for your static cookies. The question is, how to use the cookie-free domain in WordPress? 1. Create a subdomain. For example, static.yourwebsite.com and configure it to receive all the static data. 2. Redirect the created subdomain to wp-content in your host. If you use cPanel, follow the image below. Change Document Root to public_html/wp-content. 3. In your host, look for the wp-config.php file and add the following code to it, or if the code already exists, replace it with the following: define("WP_CONTENT_URL", "http://static.yourwebsite.com"); define("COOKIE_DOMAIN", "www.yourwebsite.com"); 4. Now you must redirect all the posts to the new subdomain. Simply, run the following command in the SQL Database:

  3. UPDATE wp_posts SET post_content = REPLACE(post_content,'www.yourwebsite.com/wp- content/','static.yourwebsite.com/') That’s all you need to do. By following the steps mentioned above you can simply configure the created subdomain to receive static cookies. The next method is by using NGINX. If you would like to receive static data in the server, the first is step is to provide a cookie-free domain. The next step is to connect the new domain to the same server your main domain is. The first domain is the main domain and the second domain is the static domain. Now it’s time to modify the ngix.conf file. Add the following code to the ngix.conf file: server { listen ip:80; server_name maindomain.com; root /srv/http/nginx/ maindomain.com; access_log logs/ maindomain.com.access.log; location / { index index.html; charset utf-8; } } } server { listen ip:80; server_name static.maindomain.com; root /srv/http/nginx/maindomain.com; location / { if ($request_filename ~ "\.(jpg|css|gif|png|swf|ico|mp3)$") { break; } return 404; } } The next step is to load the images through the static domain, static.maindomain.com. Simply, reference static data to the domain. Before: <img src="/images/testimage.png" /> After: <img src="https:// static.maindomain.com/images/testimage.png" />

  4. Now if there’s any request for the image, it will be requested from the static.maindomain.com. Use Cookie-Free with CDN Using CDN is another useful method to use the cookie-free domain in WordPress. Most CDN comes with the ability to ignore cookies. However, choosing the right CDN could be difficult. As you know, each CDN comes with a unique feature. Thus, using all of them can’t be a good solution. We are not going to discuss which CDN can cause issues. We would like to introduce a useful and right CDN to you. Our recommendation is KeyCDN. To use this CDN on your website you can use its plugin. Follow the steps below: 1. First, head over to the official KeyCDN website and create a new account. This website allows its users to use one month for free and if your happy with the services, purchase the full package. 2. From the official WordPress website, download the CDN Enabler plugin. Install and activate it. 3. From KeyCDN Dashboard, create a new Pull – Zone.

  5. 4. Copy the address of the created zone and paste it in the WordPress plugin you installed. Paste the copied URL here:

  6. Once everything is done, delete your website’s cache.  This is everything you should do. To make sure you have followed the steps correctly, use one of the website analyzers tools to check your website. Gtmetrix is Still Showing the Cookie-Free error One of the most commonly occurred errors users deal with is the cookie-free error in Gtmetrix. Even when you have tried every possible way to fix it. What’s still causing it? Well, if you have Strip Cookies and Cache Cookies enabled in KeyCDN, you will still see the error in the analyzer. This is known as the false-positive rule.

  7. As mentioned above, when you set cookies on your main domain, all subdomains will use cookies as well. Even the CDN URL will use cookies. If you have Strip Cookies option enabled, the YSlow error is wrong. In fact, YSlow doesn’t check if you have this option enabled or not, which is why you receive it. If you use a cURL in Chrome’s Dev tool, you can ignore this message. In addition, if you are using Cloudflare, you can’t reach 100 in YSlow that easily. Cloudflare uses _cfduid cookie for each request and due to security purposes, you can’t delete it. Therefore, you will receive the cookie-free domain error.

More Related