Tuesday, January 3, 2023
HomeWordPress DevelopmentHow To Use Cookie-Free Domains: A Full Information

How To Use Cookie-Free Domains: A Full Information


Does your web site endure from sluggish efficiency and excessive community visitors? The place cookies are sometimes the offender, one efficient answer is to make use of cookie-free domains.

Although cookies are one of many main cornerstones of our on-line expertise, they aren’t at all times as tasty as their identify would possibly recommend. Past privateness and safety issues involving third-party cookies, cookies which are routinely connected to your web site’s pictures and different static content material can have a extreme influence on web page efficiency.

Fortunately, it’s potential to trim the lifeless weight (on this case, lifeless cookies) by utilizing cookie-free domains. On this full information, we’ll overview the fundamentals of cookie-free domains, why they’re so helpful, and how one can configure your WordPress web site to make use of them.

However first, let’s attain into the digital cookie jar and take a better take a look at how domains use cookies — for higher or worse.

What Are Cookie-Free Domains?

Cookie-free domains are components of a web site that don’t ship cookies to customers’ browsers.

However why not ship cookies on a regular basis? In any case, wouldn’t it’s well mannered to present customers as many cookies as potential?

Not essentially. Once we’re speaking about cookie-free domains, we’re after all referring to HTTP cookies. In contrast to our favourite baked treats, HTTP cookies are little packets of knowledge that web sites ship to customers’ browsers. Whereas not very tasty, they’re extraordinarily helpful for permitting web sites to “keep in mind” customers the following time they go to.

Nevertheless, similar to precise cookies, you don’t need to serve too many HTTP cookies. As we’ll see shortly, guests love just a few cookies — however any greater than what they want will make them really feel sluggish and bloated.

Does your web site endure from sluggish efficiency and excessive community visitors? 👀 Cookie-free domains may very well be the answer 🍪🚫Click on to Tweet

What Are HTTP Cookies?

HTTP cookies are in every single place on the internet.

Everytime you go to a web site, there’s an excellent likelihood that the web site will ask you to retailer cookies along with your browser. Along with details about the web site itself and the web page you’ve visited, cookies embrace a private identifier tied to you and your browser. This identifier permits the web site to “keep in mind” for those who’ve already visited the web page.

Let’s take a better take a look at how this cookie change works (spoiler alert: there aren’t any charming wicker baskets or lady scouts concerned).

How websites send HTTP cookies to users’ web browsers
How web sites ship HTTP cookies to customers’ net browsers

As proven within the picture above, the change may be damaged down into three steps:

  1. Your browser requests an online web page. If you enter an deal with (e.g., a website URL resembling “kinsta.com”) into your browser’s deal with bar or click on on an online hyperlink, your browser generates an HTTP request that tells the web site that it desires to view the web page. This request is shipped to the online server that hosts the web site and its pages.
  2. The net server sends the web page and the cookie. Upon receiving your request, the online server sends again the requested web page and a cookie containing sure data. As we talked about earlier, this cookie virtually at all times features a private identifier for you and your browser.
  3. The browser requests one other web page from the identical server. Now let’s say you click on on a hyperlink to a different web page on the web site, resembling “Store” or “About Us” on an ecommerce web site. Right here, your browser sends one other request to the online server and the cookie it was initially given. When the online server receives this request, it sees the cookie it despatched beforehand and remembers you’ve already visited. With that data, the online server can ship extra customized experiences, resembling sustaining an lively login or objects in a procuring cart.

There are additionally totally different cookies for various functions. Within the instance above, the online server engaged in session administration maintains your login or procuring cart objects — in different phrases, your particular person session on their web site. Equally, cookies can be used to ship customized experiences, resembling exhibiting current orders, seen objects, and even focused commercials.

Whereas it would sound good to be given cookies wherever you go, it’s not all the things it’s cracked as much as be. As we’ll see within the subsequent part, it’s really potential for a web site to ship too many cookies — a few of which many individuals would reasonably not “eat.”

How Domains Use HTTP Cookies

Although private identifiers are one crucial use for HTTP cookies, they aren’t the one ones. In actual fact, cookies can be utilized for a variety of functions to supply extra customized net experiences, ship focused content material, and extra.

How cookies might be used to violate privacy
How cookies is likely to be used to violate privateness

We already coated how web sites and browsers change HTTP cookies to “keep in mind” you. Whereas that may be useful for sustaining login periods and exhibiting procuring cart objects, cookies can be used for extra nefarious (or outright annoying) functions.

Listed here are a number of the commonest methods domains use HTTP cookies.

  • Session administration. You already know this one by now. Session administration is commonly thought-about probably the most “benign” use for HTTP cookies, as its sole objective is to ship a constant consumer expertise that helps the consumer keep away from having to repeat sure actions. Whereas seeing earlier exercise would possibly current privateness issues for some customers, it’s comparatively innocent. The true privateness points come when cookies are used for monitoring, which we’ll cowl shortly.
  • Personalization. Session administration can be used to personalize net pages based mostly on consumer preferences and exercise. For instance, after deciding on their language of selection, customers will be capable to view the web site in that very same language on subsequent visits with out having to vary it each time. Cookies may enable web sites to adapt to the particular necessities of totally different net browsers.
  • Monitoring. Cookies even have a controversial facet. Since your browser shops the cookies web sites offer you, these cookies can be utilized to trace you in every single place you go on the internet. For instance, you would possibly go to a web site that provides your browser a monitoring cookie letting affiliated advertisers across the net know that you just visited their web page. When advertisers discover this cookie, they will show focused advertisements for the unique web site and even use it as a vector for cyber assaults. In any case, monitoring cookies could make it really feel such as you’re being “adopted” — one thing that comes with a slew of moral and privateness issues.

Fortunately, most HTTP cookies are used for session administration and personalization. Nevertheless, even probably the most harmless cookies could cause issues.

Thus far, we’ve explored the thought of 1 web page sending one cookie. In actuality, one web page normally sends a number of cookies, typically one for every web page ingredient — HTML, picture information, and so forth. Whereas a few of these cookies are obligatory for session administration and personalization, lots of them aren’t.

Consequently, it’s potential to ship too many cookies, and this will trigger a number of issues. We’ll focus on these issues within the subsequent part.

Consuming Too Many Cookies

In contrast to most paperwork, net pages are a group of varied components that give them kind, construction, and which means. Every of those components can have its personal cookie.

Whereas common paperwork we would view in a .pdf or .docx format would possibly look like a single “mixture” of textual content and pictures, net pages are constructed of many separate, small components.

HTML, CSS, and JavaScript are major components of most websites
HTML, CSS, and JavaScript are main elements of most web sites

For instance, if you request an online web page, you’re really requesting separate web page elements, resembling HTML (construction), CSS (fashion/formatting), JavaScript (interactivity), and media, resembling pictures. As such, when your browser receives an online web page, it’s really receiving and re-combining these elements to show the whole web page in your display.

If the online server can also be sending cookies, it might routinely ship a cookie with every ingredient throughout this course of. Which may not imply a lot for a easy net web page with just a few pictures, however it may well shortly get overwhelming if an online web page has tens and even tons of of various elements — and is sending a cookie for every one.

Similar to consuming too many cookies in actual life, sending and receiving too many HTTP cookies results in sluggish efficiency. Since sending further knowledge requires further time and assets, sending cookies together with each ingredient can simply devour an enormous quantity of community assets.

Area Weight-reduction plan: Going Cookie-Free

Fortunately, the answer to sending too many cookies makes use of a real-world analogy: To enhance efficiency, merely eat (learn: ship) fewer cookies.

However which cookies are we supposed to surrender? Typically, it’s greatest apply to take away cookies from any static components in your web page.

Static components are those who you gained’t anticipate to vary with consumer conduct, resembling static pictures or static information, like CSS information. Consequently, they don’t want cookies connected to them, making eradicating them probably the greatest methods to scale back community load and enhance efficiency.

In fact, eradicating cookies isn’t so simple as unchecking a “cookies” checkbox.

As an alternative, net servers use cookie-free domains to distribute static content material with out cookies individually from content material with cookies. A cookie-free area is normally a separate area (resembling a subdomain or FQDN, like “static.kinsta.com” or “kinsta.com”).

Structure of a URL showing a subdomain
Construction of a URL exhibiting a subdomain

Fortunately, it’s not very exhausting to make use of cookie-free domains if you’re utilizing the best instruments — and organising a subdomain isn’t the one technique of doing so.

However earlier than we get our arms soiled, let’s discover a number of the largest advantages of utilizing cookie-free domains and simply how massive of an influence this will have in your web site (and your funds).

Why Use Cookie-Free Domains?

Eradicating further cookies could sound like a small motion — and albeit, it’s.

Nevertheless, this small motion comes with some fairly massive advantages. By solely sending the cookies you want, you’ll lighten your community visitors and reap most of the different advantages discovered beneath — a few of which don’t have anything to do with efficiency in any respect.

Reduces Pointless Community Site visitors

Most advantages of utilizing cookie-free domains stem from lowering community load from pointless cookie visitors.

As we coated earlier, sending web page components to your guests requires a certain quantity of community assets. Past the weather themselves, every ingredient (and even a number of components of the identical ingredient) are despatched with response headers containing routing data, together with different components resembling cookies.

Although cookies are comparatively small knowledge information, having to ship a number of them with each web page request can shortly add up. Consequently, customers have to attend longer for the web page to load as your poor net host will get overwhelmed (and, in consequence, goes over funds).

In case you use cookie-free domains, nonetheless, you’ll get rid of a lot of the bulk brought on by sending pointless cookies.

Improves Web site Efficiency

As you may think, lowering community load by lowering cookies has a big influence on loading occasions and web site efficiency.

Since each web page click on is a separate request to the online server, customers could discover themselves ready for prolonged intervals simply to carry out fundamental navigation (Residence Web page > About Us > Store, and so on.). Whereas web page components and cookies could get cached and reused after the primary hundreds, this will nonetheless current an issue if the pages change or the consumer dives even deeper into your web site.

Advantages web optimization and Person Expertise

By lowering pointless visitors to enhance web site efficiency, your web site may additionally see advantages relating to SEO (web optimization) and, after all, buyer and consumer expertise.

Buyer expertise is the obvious profit: with a shorter load time, customers can entry the content material they need extra shortly. Consequently, they’ll be extra more likely to discover your web site (and your services or products) and fewer more likely to click on away in frustration.

The identical profit additionally applies to web optimization. Whereas web page loading occasions don’t immediately have an effect on web optimization, your bounce charge — the proportion of tourists who click on off your web page — definitely does.

Shoppers don’t want to wait long for a page to load
Web page load speeds

Based on a report from Unbounce, three-quarters of shippers will abandon a web page if they’ve to attend 4 seconds or longer for it to load.

Which means that even when eradicating pointless cookies improves your load occasions by solely a second, you’ll nonetheless see an enormous discount in bounce and, in consequence, a lift in your search rating.

Lowers Internet hosting Prices

Community visitors in the end prices cash in hosting charges.

Meaning for those who’re sending extra cookies than you want, you’re additionally paying far more in hosting charges. And if cookies are impacting web page efficiency, the injury is doubled: Along with paying for extra visitors, you’ll have to pay for much more to get the identical return because of the elevated bounce charge brought on by gradual load occasions.

Fortunately, managed internet hosting companies like Kinsta might help you absolutely make the most of your web page visits. Kinsta gives APM instruments and different options that will help you take advantage of your WordPress web site.

Cookieless Future Readiness

Lastly, whereas it might not be a direct profit now, delivering cookie-free content material will enable you higher put together for a cookieless future.

With cookie controversy on the rise in gentle of privateness necessities, such because the GDPR, many main serps, and expertise firms are searching for methods to get rid of cookies altogether. Whereas cookies in all probability gained’t go away for a while, they very nicely would possibly ultimately — and the earlier you’re prepared for it, the simpler the transition shall be.

Strategies of Utilizing Cookie-Free Domains

As we coated earlier, the overall thought of a cookie-free area is to ship static content material with out delivering cookies. Although making a separate static area or subdomain is probably the most direct method to do that, it’s additionally potential with CDNs and a few WordPress tips.

Create a Separate, Cookie-Free Area

With this technique, you’ll create a separate area for internet hosting your web site’s static elements, resembling pictures and CSS.

When you can register a completely separate area identify, it’s normally simpler and less expensive to create a subdomain of your current area identify. Most cookie-free domains merely use a static prefix (e.g., “static.yourdomain.com”) as their subdomain.

Be aware that this may solely work if the “www” model of your area (e.g., “www.yourdomain.com”) is the foundation area in your web site’s root file.

To make the subdomain cookieless, you’d usually have to seek out and edit your .htaccess file immediately utilizing particular code. Nevertheless, as we’ll see later, it’s a lot simpler to easily reconfigure your WordPress web site or use a plugin.

Nevertheless you configure your cookie-free subdomain, you’ll be able to add static elements, resembling your CSS elements, pictures, textual content, and JavaScript.

Use a Content material Supply Community (CDN)

Utilizing a content material supply community or CDN is a particularly handy method to make use of cookie-free domains.

Right here, reasonably than having to create separate subdomains and edit configuration information, you’ll be able to merely inform your CDN to disregard and strip cookies from the response headers of your static elements. That will sound a bit difficult, but it surely’s really a easy function in lots of CDNs.

Be aware that not each CDN gives this performance. Consequently, it’s typically higher to vary your web site’s configuration except you’re already utilizing a CDN that lets you disable cookies.

Reconfigure Your WordPress Website

In case you’re utilizing WordPress, you’re in luck: All it takes to designate a cookie-free area is to replace a few strains in your wp-config.php file. Skip forward to the following part (Configuring WordPress to Use Cookie-Free Domains) for full directions.

Use a WordPress Plugin

One other straightforward WordPress possibility is to make use of a plugin for creating static variations of WordPress web sites.

One in style plugin for doing that is WP2Static (actually “WordPress-to-Static”). After putting in the plugin, merely open it in your WordPress dashboard and configure the settings to export your web site to a static model:

Creating a static version of a WordPress site in WP2Static
WP2Static

Configuring WordPress to Use Cookie-Free Domains

As talked about above, WordPress gives a simple strategy to implement cookie-free domains. The method boils down to a couple easy steps:

  1. Including an alternate subdomain and related DNS
  2. Telling WordPress which area will serve up static property
  3. Updating current WordPress database data to mirror this new deal with

Kinsta prospects can use the MyKinsta dashboard to perform a few of these duties. Many different WordPress customers will be capable to do the identical in cPanel.

We’ll cowl each beneath.

Utilizing MyKinsta To Arrange a Cookie-Free Area

Kinsta prospects can affiliate subdomains (or utterly totally different domains) with a WordPress occasion inside the MyKinsta dashboard. Many shoppers may even use MyKinsta’s instruments to configure DNS for these domains.

On this instance, we’ll create a cookie-free area at static.instance.com for our web site already up and working at www.instance.com.

Step 1. Create a Subdomain in MyKinsta

In case you initially established your WordPress web site at Kinsta utilizing the wildcard possibility with its area identify (like: *.instance.com), you might be already set to assist any subdomain identify. If not, you’ll be able to add the brand new area for cookie-free content material like this:

  • Choose WordPress Websites on the left-hand menu.
  • Click on on the identify of your WordPress web site.
  • Choose Domains on the left-hand menu.
  • Click on the Add Area button.
Screenshot: Adding another domain within MyKinsta.
Including a subdomain inside MyKinsta.

Within the following dialog:

  • Sort the identify of your cookie-free area.
  • Click on the Add Area button.
Screenshot: Typing a new domain name within MyKinsta.
Specifying the brand new subdomain inside MyKinsta.

Subsequent, your new static area will want a DNS file pointing to your current web site. In case you handle DNS to your domains by means of a third-party supplier, you’ll use their instruments to try this. In case your DNS is offered by us, configure your new area in MyKinsta like this:

  • Choose DNS on the left-hand menu of the MyKinta dwelling web page.
  • On the DNS Administration web page, scroll right down to the DNS Data block and click on the Add DNS Document button.

We suggest including your new subdomain to DNS as a CNAME file, permitting you to depend on simply the second-level area identify for associations with IP addresses. Beneath, we’re including a CNAME file for static that factors to instance.com:

Screenshot: Creating a DNS record within MyKinsta.
Making a CNAME file in MyKinsta DNS administration.

Step 2. Disable Cookies on Your Static Subdomain

Now we’ll edit your WordPress web site’s wp-config.php file in order that property inside the wp-content folder are served up from the “static” area and cookies are delivered solely by way of the “www” deal with.

Most Kinsta prospects will use an FTP/SFTP shopper to login to their WordPress web site and obtain wp-config.php to their desktop for modifying:

Screenshot: Downloading wp-config.php with an SFTP client.
Downloading the wp-config.php file to the desktop.

Use a textual content editor so as to add the next strains to the wp-config.php file (changing the instance domains with your individual personal):

outline("WP_CONTENT_URL", "https://static.instance.com/wp-content");
outline("COOKIE_DOMAIN", "www.instance.com");

After saving the file, add it to your WordPress web site, changing the earlier model.

Step 3. Redirect Present Belongings to the Subdomain

The steps above will enable cookies to be handed out when browsers load content material like pages and weblog posts from the “www” deal with, however will trigger content material like media uploads and property like JavaScript, CSS and fonts inside themes to be related to the “static” area.

Nevertheless, your web site could have already got content material that comprises hyperlinks to these property on the “www” deal with. You’ll be able to clear that up with a bit of search-and-replace within the WordPress database itself.

At all times again up your WordPress web site earlier than working within the database. After that’s performed:

  • Choose WordPress Websites on the left-hand menu of the MyKinsta dashboard.
  • Click on on the identify of your WordPress web site.
  • Choose Domains on the left-hand menu.
  • On the Website Info web page, scroll right down to the Database Entry block. (You’ll be able to copy database username and password data right here if wanted.)
  • Click on the Open phpMyAdmin hyperlink.
  • Login to your WordPress database.
  • Click on the SQL tab.
Screenshot: Updating content in the WordPress database using phpMyAdmin.
Working an SQL question to replace asset hyperlinks in WordPress content material.

Run the next command to make sure that any asset hyperlinks inside your current posts are directed to your cookie-free subdomain (once more, being positive to interchange the domains with your individual):

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

You’ve now efficiently configured a cookie-free area in WordPress with the assistance of MyKinsta. Use this area to host any static content material for which you don’t need to ship WordPress cookies and use your common area for all the things else.

Utilizing cPanel To Arrange a Cookie-Free Area

Listed here are the steps to perform what we did above in MyKinsta utilizing cPanel or one of many in style cPanel alternate options.

Step 1. Create a Subdomain in cPanel

Navigate to the Domains part of the cPanel major web page. Within the Subdomains instrument, merely create a subdomain linked to the top-level area of your present WordPress web site.

These settings may be seen beneath to create the subdomain static.instance.com.

Creating a subdomain in cPanel
Making a subdomain in cPanel

Step 2. Configure the Subdomain as Static in cPanel

Together with your new static subdomain able to go, it’s time to make it dwell as much as its identify by making it serve static content material in WordPress.

We’ll do that by modifying your WordPress web site’s wp-config.php file. The best strategy to entry this file is in cPanel’s File Supervisor instrument.

In File Supervisor, navigate to your web site’s public_html folder and choose wp-config.php (1). Then, choose the Edit possibility (2) to edit the file.

Locating the wp-config.php file in the cPanel File Manager tool
Find the wp-config.php file

Within the wp-config.php file, merely add the next strains (being positive to interchange the domains with your individual!):

outline("WP_CONTENT_URL", "https://static.instance.com/wp-content");
outline("COOKIE_DOMAIN", "www.instance.com");

Click on “Save Modifications.”

Step 3. Redirect Present Posts to the Subdomain

Lastly, you’ll have to redirect your current posts to the brand new static subdomain. However first, you should definitely again up your WordPress web site simply in case it doesn’t perform correctly after.

Within the Database part of cPanel, open the PhpMySQL instrument. Choose your web site’s database after which its _posts desk.

Click on the SQL tab of the _posts desk. Run the next command to confirm that your submit URLs are directed to your cookie-free subdomain (once more, being positive to interchange the domains with your individual):

UPDATE wp_posts SET post_content = REPLACE(post_content, 'www.instance.com/wp-content/', ' static.instance.com/wp-content/')
Redirecting existing posts to the new static subdomain
Redirecting current posts to the brand new static subdomain

And that’s it! You’ve now arrange a cookie-free area in WordPress with the assistance of cPanel. Use the cookie-free area for static content material like pictures, CSS, JavaScript, and fonts, whereas permitting cookies in your web site’s main area.

Cookie-free domains might enable you lighten your community visitors… & extra. 🚫🍪 Learn on to study extra ⬇️Click on to Tweet

Abstract

Utilizing cookie-free domains is a extremely efficient method to enhance your web site efficiency, scale back internet hosting prices, and even improve your buyer expertise and web optimization.

As we’ve seen, organising cookie-free domains in WordPress is useful. Nevertheless, solely a managed WordPress host like Kinsta can take full benefit of those advantages.

With handy instruments for eradicating set-cookie headers and direct database entry to redirect posts to a static subdomain, it’s by no means been simpler to make use of cookie-free domains. Kinsta’s APM instruments and different performance-monitoring options may enable you monitor the outcomes.

For extra data and to see Kinsta for your self, contact us or schedule a free demo at the moment.


Get all of your functions, databases and WordPress websites on-line and beneath one roof. Our feature-packed, high-performance cloud platform consists of:

  • Straightforward setup and administration within the MyKinsta dashboard
  • 24/7 skilled assist
  • One of the best Google Cloud Platform {hardware} and community, powered by Kubernetes for optimum scalability
  • An enterprise-level Cloudflare integration for velocity and safety
  • International viewers attain with as much as 35 knowledge facilities and 275+ PoPs worldwide

Check it your self with $20 off your first month of Software Internet hosting or Database Internet hosting. Discover our plans or speak to gross sales to seek out your greatest match.



RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments