Site icon Theembazaar

Why you should use WordPress CDN in 2022

Why you should use WordPress CDN in 2022

As a performance hosting company, it’s important for us to research ways to speed up WordPress and share the results of that research. Using a content delivery network (CDN) is one of today’s most common ways to speed things up. A CDN improves visitor satisfaction by reducing the load on your web server and speeding up the delivery of content to your visitors!

Today, I’ll explain how WordPress CDN works , how to use it, and some of its special benefits. In addition, we will also introduce the results of some speed tests so that you can judge the degree of performance improvement of the website.

What is a WordPress CDN?

CDN is simply an abbreviation for content delivery network. Content delivery networks are server networks around the world for hosting static (and sometimes dynamic) content for WordPress websites, such as images, CSS, JavaScript, and video streams.Support Support

CDN overview

First of all, it’s a completely different purpose, so don’t confuse your CDN with your WordPress hosting company. CDNs are not an alternative service for hosting companies, but an additional service that speeds up your website. Even if you have a rapid Theembazaar from the beginning, you can further improve the speed by using the CDN.

What is the idea of ​​a CDN? For example, if you are hosting your website on TB, choose a data center location such as Central US, Europe, South America, or Asia . For example, suppose you select the United States Central. In that case, the website is physically located on the “host server” of Council Bluffs, Iowa. In that case, when a customer from Europe visits the website, the load time will be longer than, for example, a customer in Dallas, Texas. Why. That is because the distance traveled by the data is long. This is called latency . Latency is the time it takes to send data over a network and its delay. The farther the distance, the longer the latency.

In addition, some network hops (communication steps between communication partners) are required to deliver data requests from the browser to the hosting server and to deliver content from the corresponding hosting server to the browser. Here’s where the CDN comes in handy. The CDN reduces latency by loading website content from nearby servers. These CDN servers are also known as POP (Point of Presence).

CDN reduces latency

Many WordPress users don’t want to think too much about the content delivery network because it’s hard to understand. Here’s an overview of CDNs and how to use them in three simple steps, in the language of the general public.

step 1

Select a CDN provider and sign up. Usage fees are usually billed monthly or by data usage. Most providers have a calculator to estimate their costs.

Step 2

Integrate your CDN into your website using a free plugin such as CDN Enabler or WP Rocket . These plugins automatically link your assets to your CDN. There is work to manually put the content into the CDN. It’s completely automatic! The introduction of CDNs is much easier than it was a few years ago.

Step 3

When a visitor visits your website, the content of your website is loaded from various CDNs around the world. If you are visiting a website in Iowa from Europe, the content will be loaded from the European POP. How can this be done? CDNs typically use two methods to determine a user’s location. The two methods are IP Anycast and location routing . It automatically detects where the user’s request came from and routes the request to the nearest POP.

However, it is important to strategically choose a server location for your WordPress hosting company. The CDN improves media and content delivery, but it still requires one request to the hosting company when the website loads. (Unless you’re using a full-page cache on a proxy server, we’ll talk about that later.) TB has 29 data centers that can host WordPress websites .

Benefits of CDN

Here are some of the benefits of using a CDN on your WordPress website.

1. Performance improvement

Performance improvements are one of the biggest reasons to use a CDN. Faster load websites have proven to improve the user experience, as well as higher conversion rates, lower bounce rates, and longer average visits. You too are sure that the website loads slowly and you may leave it alone. I want to avoid this on my website. You don’t have to really take what this article says, so be sure to check out the data below from the leaders in the digital industry.

Here are some ways CDNs can help improve the performance of your WordPress website, for example:

Reduce TTFB

As mentioned above, WordPress CDNs can reduce latency by reducing the physical distance required to move data . The CDN also shortens the ” time until the first byte arrives ” (Time To First Byte, TTFB). Simply put, TTFB is the time it takes for the browser to receive the first byte of data from the server. The longer it takes to receive that data, the longer it will take to display the page.

CDN may shorten TTFB

A common misconception is to use DNS lookup time to calculate TTFB. However, the true calculation of TTFB in networking includes network latency. This involves a three-step process, which can have delays or latencies anywhere in between, resulting in a long total TTFB. There are many reasons why a long TTFB can be due to a code error on the host server, a caching misconfiguration, and so on. So, of course, geographical distance is one of the causes. We tested it using a TB CDN (using a KeyCDN) to show that. Each test was run 5 times and averaged.

TTFB without CDN

First, I disabled the CDN and tested it. The total load time was 1.45 seconds and the average TTFB for the asset was about 136 ms.

TTFB before inserting the CDN

TTFB with CDN

Then I re-run the test with the CDN enabled . As you can see, the total load time has dropped to 788ms and the average TTFB is now 37ms! CDNs make a difference. And it’s also very important to have Stockholm as the location to run the tests. Why. Of course, I wanted to show how much the results improved. There is a CDN POP in Stockholm, so the content is delivered from Stockholm.

CDN after inserting TTFB

Note: If you are using Cloudflare, TTFB may be a little longer . The reason is certainly the increased overhead, or the full proxy service running. Cloudflare adds features not found in firewalls or other CDN providers. So you have to decide for yourself which method is most appropriate for you. If your website isn’t fully optimized, Cloudflare may be worth it even if your TTFB is a bit longer.

See the WP Bullet article for information on how to use Cloudflare’s page caching to lower TTFB. This may require additional setup and testing. Be sure to run your own tests as each environment is different. Also, Cloudflare’s new feature Argo may help shorten TTFB.

Speed ​​up delivery by caching

Just as a cache is available on a WordPress host or plugin, a CDN also uses a cache. Caching is one way CDNs can deliver files quickly. However, it is important to have an overview of caching. It requires one or two requests from the visitor before the CDN gets a copy of the media and the media is actually cached in the CDN. The CDN places an HTTP header in the request called “X-Cache”. On the first or second request, the file will appear as “MISS”. That is, it has not been cached yet.

CDN is not cached (MISS)

Subsequent requests will see it as a HIT, so it’s already cached on the CDN at that time. It remains cached due to various factors, such as ETag headers, Expires headers, or manually purging the CDN cache.

Cached CDN (HIT)

If you have a full proxy CDN such as Cloudflare, you can use a full page cache for even more advanced caching. This is to cache everything on the URL. However, using the full page cache is a bit complicated because WordPress websites need to implement workarounds for dynamic content.

Huge savings with GZIP compression

The WordPress CDN also utilizes the file format and software application GZIP used for file compression and decompression. GZIP compression is enabled on the server (or CDN server / POP) side to further compress the size of HTML, stylesheets, JavaScript files, etc. The image is out of scope because the image has already been compressed in another way. Some have confirmed a savings of up to 70% with compression. Compression is probably one of the easiest optimization methods. Or rest assured that all major CDNs have compression enabled by default.

You can check the improvement level by compression with tools such as Check GZIP Compression or Chrome Dev Tools. For example, in the example below, GZIP compression of the jquery.js file delivered from the CDN reduced the size from 94.9 KB to 33.6 KB. That’s a 64.59% savings for just one file. Compressing all your assets or media is an impressive result! Compression is still essential.

Savings with GZIP compression

Advanced compression with Brotli compression

Brotli is a new compression algorithm developed by Google that can compress file sizes up to 26% more than existing solutions such as GZIP . Brotli adoption is growing fairly rapidly. As of June 20, Google is even considering compressing display ads with Brotli compression.

Savings with Brotli compression (Source: SamSaffron )

However, because Brotli is new, it is not yet available for many CDN providers, but there are also providers such as KeyCDN and CDN77. In most cases , Brotli will not work unless you also enable Brotli on your origin server ( hosting server )Brotli’s browser support is also evolving. If the settings are correct, Brotli will simply revert to GZIP when you try to load Brotli from a enabled server with a browser that doesn’t support Brotli.

HTTP / 2

HTTP / 2 is a method used by all CDNs to speed up the delivery of assets. HTTP / 2 requires HTTPS for browser support. There are several reasons for performance improvements, such as the protocol’s ability to support better multiplexing, parallelism, Huffman-encoded HPACK compression, ALPN expansion, and server push. Previously, there was a lot of TLS overhead when using HTTPS, but thanks to HTTP / 2, this is a thing of the past.

2. Reduce band with costs

Another big advantage of CDNs is that they can reduce the load on the CPU and hosting server (origin server). This will not overwhelm your hosting server in the event of a spike in traffic. It also helps reduce the cost of band with. I want to avoid the content spreading rapidly through the internet and the hosting companies being invoiced in vain. For example, the example below is a website using Cloudflare. The burden of band with request was reduced by 69%.

Cloudflare Band with Savings

Another way a CDN can help reduce costs is to provide an easy way to enable hotlink protectionHotlink protection basically limits the HTTP referrer and prevents others from embedding your assets (images: see also the tutorial on how to protect images ). Some readers may be familiar with the Huffington Post case . A Huffington Post reporter copied and pasted an image from Oatmeal ‘s website, and Oatmeal charged AWS over $ 1000. The owner of Oatmeal eventually replaced the image and showed the fact to the readers of the Huffington Post article. It became clear in this case that it was always important to enable hotlink protection . Otherwise, it can cost you money.

Hotlink protection

3. High availability and scalability

CDNs also provide high availability and scalability. Content is served by multiple POPs in different geographic locations, so if one server breaks, web traffic is dynamically routed to another. And because your CDN provider is built with scalability in mind, you don’t have to worry about scalability. If you’re using a small shared hosting company, the CDN handles most of the load and protects your website from crashes.

4. Benefits of SEO

Google included website speed as a ranking factor in 2010, so it’s not surprising that the faster your website, the higher your ranking score. There is no way to know how much speed affects your score, but you can think of it as one of the most important factors as it affects the user experience. Brian Dean analyzed the top 1 million domains to find a correlation between website speed and Google’s rankings . The findings were very positive. Such exams are hard to prove definitively, but if your website is fast, Google’s ranking will definitely improve. Google likes fast websites.

Website speed and Google rankings

CDNs help speed website pages as well as increase the crawl rate of media such as images. This is related to indexing with Google Image Search.

5. Additional security

Many CDN providers offer additional security by allowing you to implement something called a web application firewall (WAF) and origin shield. This avoids a wide range of DDoS attacks such as UDP and ICMP protocol attacks, SYN / ACK, DNS amplification, and Layer 7 attacks on WordPress websites. Alternatively , you can take advantage of a proxy that hides the original IP address , but this system is not bulletproof.

Check out our case study on how . Case study customers have a small e-commerce site using Easy Digital Downloads. At one point, within 7 days, there were more than 5 million requests on a single page . This website typically generated only 30-40MB and hundreds of visitors a day with a band with. But suddenly there was a 15-19 GB data transfer a day! That’s an increase of 4650%. No additional traffic was seen in Google Analytics. I’m in trouble.

DDoS attack

When the customer implemented Sucuri’s web application firewall on their website, the band with and requests dropped sharply (see below) and there have been no recurrences since then. When such issues occur, web application firewalls are definitely a good investment or time saver.

After adding Sucuri’s WAF

The CDN also has additional features such as a secure token that can generate a secure link with an expiration date. After it expires, you will not be able to access the content.

CDN speed test

In addition to explaining the benefits of the WordPress CDN, we will also conduct actual tests and introduce the results. We ran 5 tests from 4 locations with and without a CDN. The website is hosted on TB and uses TB CDN (KeyCDN). The location of the server is Iowa, USA.

When speed testing a CDN, it’s important to run the test several times to ensure that the media is cached. As mentioned above about CDN caching, the X-Cache HTTP header will display “HIT” when cached. If it is not cached, “MISS” is displayed. Please note that if you do not test correctly, the CDN will not seem to help speed up your website.

No CDN (Dallas, Texas, USA)

First, we tested five times without a CDN from Dallas, Texas, using Pingdom, and averaged them.

Test without CDN, Dallas (Source: Pingdom)

No CDN (Melbourne, Australia)

After that, I did five tests without a CDN from Melbourne, Australia using Pingdom and averaged them.

Test without CDN, Australia (Source: Pingdom)

No CDN (San Jose, CA, USA)

We then performed five CDN-free tests from San Jose, CA using Pingdom and averaged them.

Test without CDN, San Jose (Source: Pingdom)

No CDN (Stockholm, Sweden)

After that, I did five tests without a CDN from Stockholm, Sweden, using Pingdom and averaged them.

Test without CDN, Sweden (Source: Pingdom)

With CDN (Dallas, Texas, USA)

First, we tested with a CDN five times from Dallas, Texas, using Pingdom, and averaged them.

Test with CDN, Dallas (Source: Pingdom)

With CDN (Melbourne, Australia)

After that, I did 5 tests with a CDN from Melbourne, Australia using Pingdom and averaged them.

Test with CDN, Australia (Source: Pingdom)

With CDN (San Jose, California, USA)

After that, we tested 5 times with a CDN from San Jose, CA using Pingdom and averaged them.Are you suffering from downtime or WordPress anomalies? TB is a hosting solution designed to save you time! Check out our features.

Test with CDN, San Jose (Source: Pingdom)

With CDN (Stockholm, Sweden)

After that, I conducted 5 tests with a CDN from Stockholm, Sweden, using Pingdom, and calculated the average.

Test with CDN, Sweden (Source: Pingdom)

result

Let’s review the results so that you can understand the impact on the CDN loading time.

CDN speed test comparison

As you can see, both Dallas and San Jose have less improvement with a CDN. However, if you look at the Australian tests, you’ll see a big improvement in load times. This is due to the geographical location of the test server. Our server is located in Iowa, so when you try to read data from Dallas and San Jose, the distance traveled by the data is not long. But in Australia, distance has a negative impact on load time. Enabling the CDN will load content and media from the TB CDN POP in Sydney, Australia, significantly improving download times. The same is true for Stockholm, Sweden.

Would you like to improve your load time by more than 50%? The answer must be yes!

Do you need a CDN?

At TB, customers are often asked if a website needs a CDN. In our experience, CDNs are beneficial in almost all cases. See the benefits listed above. Most CDN providers are very cheap, some at $ 0.04 / GB, so cost is no longer a factor. And Cloudflare is free. It’s worth further testing if you’re only serving content to visitors in a particular geographic location.

Take, for example, the website of a small store in Ontario, Canada. You probably don’t really care about customers elsewhere. In that case, you need to find out the location of the CDN provider’s POP. For example, if your web server is in Ontario, but your nearest POP contracts with a CDN provider that is only in the United States, your website can be slower. It’s a very rare example, but it’s beneficial not to use a CDN in this example.

There are many great CDN providers to choose from. Most providers offer free trials, so it’s a good idea to try a few to find the one that works best for your website. TB offers a free CDN (provided by Key CDN) for all customers. Please also check the following third party providers.

How to install a CDN into WordPress

Each CDN provider has its own integration method, but thanks to all providers support WordPress, it’s easy to integrate. If you have any problems, please check the procedure manual and contact the support team of the provider.

Cloudflare

If you’re using or are considering using Cloudflare, we have a detailed tutorial on how to install Cloudflare on your WordPress website .

Third party CDN

If you are considering introducing a KeyCDN yourself, I recommend this article about CDNs for beginners .

Our advice is that you should use subdomains for your website’s media and assets rather than the random URLs given by your provider . Example: cdn.yourdomain.com. This not only improves the branding of your website, but also makes it easier to solve indexing issues. You can set up your CDN in your provider and then use a free WordPress plugin like CDN Enabler to link your assets and automatically copy them to your CDN provider.

CDN Enabler

Plugins such as WP Rocket or W3 Total Cache have similar integration methods.

WP Rocket CDN

It’s important to load as many resources as possible from your WordPress website. This guarantees rapid delivery to visitors and the use of a single HTTP / 2 connection. You can use a tool like Pingdom to see where your website loads. For some themes or plugins, data may not be read from the CDN even after the integration is complete, which requires tweaking or investigation.

Image index registration on CDN

Finally, it’s also important to make sure your images are indexed by Google when you move to a CDN. If you’re using the Yoast SEO plugin, add the following code to the end of your function.php file. Of course, replace your domain and CDN domain with your own.

function wpseo_cdn_filter( $uri ) {
return str_replace( 'http://yourdomain.com', 'http://cdn.yourdomain.com', $uri );
}
add_filter( 'wpseo_xml_sitemap_img_src', 'wpseo_cdn_filter' );

If you do not do this, the image may be unindexed (see below). You can always check the index status on the Google Search Console .

Image is not indexed

However, there can be significant discrepancies in reporting that images are correctly indexed in the Google Search Console. To see if your image is really indexed, go to Google Image Search and type:site:https://yourdomain.com

Check index registration with Google Image Search

Note: Do not enter the URL of the CDN. Images should be indexed to the root domain even if they are delivered from the CDN. If the image is displayed in Google Image Search, it is correctly indexed.

summary

Here are some of the great benefits of WordPress CDNs. It ensures fast loading of media from all over the world, reduces TTFB, and significantly reduces band with costs and server load. Besides, the faster the page load time, the higher the ranking score. And most importantly, the user experience will improve significantly.