GTmetrix Performance Blog

News, updates and guides on GTmetrix and general web performance

A Basic Guide to CDNs and GTmetrix

Got an F on your CDN recommendation?

We’ll explain how using a Content Delivery Network (CDN) affects your GTmetrix score and how they help your page perform faster.


How does your website do on our CDN recommendation?


 

Overview

Content Delivery Networks (CDN) are a great way to ensure your page performs quick globally.

If you are unfamiliar with CDNs, have a look at our Why use a Content Delivery Network (CDN)? article to learn about how they work.

In this article, we’ll discuss in detail how CDNs affect your GTmetrix score and why. We’ll also define how CDNs generally work and how they help in improving performance for your visitors worldwide.
 


 

How do CDNs work?

CDNs store your page’s commonly accessed resources in Edge Servers all around the world.

Most CDNs work as follows; When a user requests your site, the CDN’s Edge Server closest in proximity to the user will deliver the static resource, ensuring the shortest distance for the data to travel; thereby, reducing latency.

This provides the user with a faster site experience over fetching the file from your own server (the Origin Server).

With a CDN, European users will be able to download your site’s static content faster from a Edge Server located in Europe, instead of having to retrieve them all the way from North America.

 

CDNs also help by reducing the stress on your Origin Server by fulfilling requests on its behalf.

Instead of your Origin Server handling all the requests from your visitors, the job is now distributed across multiple Edge Servers.

More advanced CDNs can not only cache your static resources, but your entire web application.

For example, Cloudflare caches your entire site (anything pointed to your domain) and hides your Origin Server completely (this is how they protect you from DDoS attacks as well).

Read our full article here: Why use a Content Delivery Network (CDN)? .

 


 

General CDN Terminology

If you’re already experienced with CDNs, feel free to skip this section. If CDNs are new to you however, there are a few important terms and concepts you should understand.
 

Origin and Edge Servers

Origin Server is where your entire site is hosted. Edge servers house static resources of your site for faster global delivery.

 

Origin Server

The server at which your website is actually hosted. This is wherever your hosting service has its data center.
 

Edge Server

One of the many servers in the CDN’s global network. Your geographic location determines which edge server delivers resources to you.
 

 


 

Cache Hit

This means the resource was served from the Edge Server’s cache.

You want as many cache hits as possible – meaning the CDN is serving the requests and not your Origin Server.

 


 

Cache Miss

This means the resource was not served from the Edge Server’s cache, and the resource was instead requested and delivered from your Origin Server.

You want as few cache misses as possible – high cache miss rate means your resources are not being reliably delivered by the CDN.

 


 

Revalidation

This means a request for a resource was made, and the CDN had it cached, but it also performed a check with the Origin Server to see if the cached resource was still valid (i.e. hasn’t changed, still correct to serve, etc.).

A failed revalidation is essentially treated as a Cache Miss.

 


 

Time to Live (TTL)

The amount of time to consider a cached request valid on the Edge Server. After this time elapses, requests typically go through revalidation (see above).

CDNs typically allow adjustments of TTL to ensure frequently updated sites always deliver the latest resources.
 

 


 

Latency

The duration of when the request was started, and a response was given.

The further a visitor is away geographically from a server, the more latency is present.

The fundamental goal of CDNs is to reduce latency by providing an Edge Server that is geographically closer to the visitor.
 


 

Routing

Routing defines which Edge Server your CDN sends you to retrieve static resources.

 

Routing is when the CDN decides to redirect requests of user to a particular Edge Server.

Good routing will redirect requests from the closest/fastest edge server to the user.

Bad routing will redirect requests form sub-optimal edge servers to the user (slower, further away, etc), either due to issues in the CDN’s performance, general errors, or internal balancing reasons.

 


 

Bandwidth

Bandwidth can refer to the speed of the transfer of request data or the amount of data transferred by the CDN (data transfer can also be called Traffic).

The faster the speed, and the more data transferred by the CDN, the better.
 

 


 

I have a CDN installed, why am I getting an F in “Use a Content Delivery Network (CDN)”?

 

There are a few reasons why you may score an F on this recommendation.

 

GTmetrix scores your CDN usage (if any) with YSlow’s “Use a Content Delivery Network (CDN)” recommendation. YSlow has weighted the impact of this score quite high, with most sites getting failing grades on this recommendation.
 

How is my CDN score calculated?

For every static request that isn’t on a known CDN, YSlow will deduct 10% per request from the “Use a Content Delivery Network (CDN)” score. The overall effect on the total YSlow score is moderate, as it is a Medium priority recommendation.
 

Every static resource not detected on a CDN will impact your score by 10% per request.

 

If you’re using a popular, well-known, CDN, GTmetrix will likely auto-detect it for recommendation. No action is necessary, and your score should reflect the CDN usage.

If you’re getting an F in this recommendation, here are a few common reasons why:

 


 

The CDN is not setup properly

CDNs are setup differently across all services. Some require just a nameserver change, others require you to edit URLs of your static requests, and others yet require a different implementation.

Contact your CDN support team to investigate why your resources aren’t being served via CDN.
 
 

How to check if your CDN is set up properly

As mentioned in our earlier How to Analyze a Waterfall Chart article, response headers are the main way to check if your requests are being served from an Origin Server or a CDN.
 

Response headers give you a wealth of insight.

 

Most CDNs provide response header data to go along with the served resources:

For example, Cloudflare typically includes these response headers with each request they serve indicating Cache HIT/MISS status, Server and CF-RAY data:
 

CF-Cache-Status HIT
Server cloudflare
CF-RAY 4e26286f58e0ce53-LHR

 

StackPath usually contains an X-HW line; short-hand code for various data related to the request (Read their documentation here)

X-HW 1557526273.cds122.ch4.h2,1557526273.cds126.ch4.sc,1557526273.cds126.ch4.pr

 


 

DNS has not fully propagated

If your CDN requires you to change your nameserver or CNAME, propagation will need to be complete before your website can properly serve requests via the CDN.

Propagation is a period of time Internet service providers (ISPs) around the world take to update their Domain Name System (DNS) with your new data – this may take up to 24 – 48 hours.

You can use these services to see how your site is doing DNS-wise globally:

Contact support from your hosting or domain registrar if you’re having issues resolving your DNS.

 


 

Only some resources are being served on the CDN

You may not have selected the appropriate locations, directories or file-types to serve via your CDN, or you have not entirely edited the URLs of your static requests to use the CDN.

This is especially the case for CDNs that offer setup via plugins or extensions, or for applications that have CDN settings.

Double check your CDN settings in your application to ensure the appropriate directories are defined for CDN delivery.

 

 


 

GTmetrix does not recognize the CDN used

While your resources may in fact be served on a CDN, GTmetrix cannot find any matches in its CDN list. Scenarios we see often are:

 

The CDN you’re using is not common

You may be using a CDN that is not widespread. This is often smaller CDN services, or niche services like CDNs for images.

GTmetrix looks at response headers and cross-references a maintained list of popular, well-used CDNs to determine the CDN recommendation score.

If the CDN is not recognized, then your score will be affected.
 

Solution: If you feel your CDN should be recognized, reach out to us and we’ll review for inclusion.
 
 
 

You have third-party requests that aren’t served on a recognizable CDN

This is a very common scenario where webpages are embedded with third-party services that GTmetrix does not recognize as CDNs.

Large services like Facebook, YouTube, etc. are recognized as using CDNs by GTmetrix, however there are a myriad of third-party services GTmetrix doesn’t recognize as utilizing CDNs.

This doesn’t necessarily mean the services themselves are not on a CDN – it just means the response header data they return does not match any CDNs known to GTmetrix.
 

Solution: Unfortunately there isn’t a solution to this (GTmetrix can’t reasonably add all third-party requests to its CDN list). The recommendation, is to audit your third-party service usage and determine if they bring you value.

An excerpt from our Guidelines for a faster Shopify, Squarespace, or Wix website article:

You should be selective of which services you add onto your website…the trade-off in performance should be worth the functionality you get out of them.

Review all of your third-party resources and be sure every service is providing you value.

 


 

Summary

CDNs offer an easy way to provide immediate performance improvements to any site.

Not only do they improve performance on a latency level, some CDNs offer image optimization, script compression and security features like DDoS protection.

Are CDNs completely necessary? No – they aren’t. If you have a low to moderately trafficked website with visitors primarily located in your server’s hosted region, a CDN might not be worth the cost or effort. However, if your site has high traffic with visitors from all over the world, a CDN is highly recommended.

Which CDN should you use? Stay tuned for our CDN Review 2019 article coming soon.

We hope this guide has given you some clarity and direction with regards to CDNs and their benefits. Feel free to reach out to us on Twitter or Facebook if you have any questions or feedback.

 


 

Keep your site’s performance at the top of mind

PRO Monitoring Splash

Get more monitoring slots and advanced options along with hourly testing with a GTmetrix PRO plan.

Available in Bronze, Silver or Gold levels – or create a Custom plan to suit your needs!

Other features include: Priority access in the queue, the Developer Toolkit bundle, Remote location monitoring, and much more!


Upgrade to PRO today!