Common CDN issues and how to fix them

If your website is still slow despite the use of a CDN, check for these common CDN problems.

Learning Objectives

After reading this article you will be able to:

  • Troubleshoot slow CDN performance
  • Fix outdated content coming from a CDN cache
  • Identify other common caching issues

Copy article link

Common CDN issues and how to fix them

A content delivery network (CDN) is a distributed group of servers that cache, or save copies of, web content for rapid delivery to end users. CDNs can help accelerate content delivery and improve user experiences in a variety of ways besides caching, such as assisting with video streaming, dynamic content, and SSL encryption and authentication.

Any website can benefit from a CDN. CDNs sit between end users and origin servers. They fill user requests with any content they have in the cache before passing requests along to origin servers. This makes a website load faster for users. It is somewhat like how buying food from a grocery store is much faster than driving across the country and visiting multiple farms and factories for one's weekly groceries.

CDN troubleshooting: How to fix CDN issues

Most of the time, signing up for a CDN should quickly make a website faster, help website operators save on bandwidth costs, improve site reliability, and increase resistance to certain cyber attacks (such as DDoS attacks). However, sometimes CDN issues prevent web properties from seeing these benefits. Here are some potential CDN issues, factors that can cause them, and recommendations for addressing them.

CDN slow performance issues

A number of issues can cause a website to fail to see performance benefits or even slow down when using a CDN.

Lack of global reach: Depending on which CDN is used, performance can be inconsistent in different regions. Be sure to use a CDN that caches content everywhere on its network and has global locations close to end users.

Origin server issues: If the CDN cannot get the content from the origin server, then it cannot cache or serve content. This can happen when origin servers experience downtime, or when traffic between origin servers and the CDN gets caught in network bottlenecks.

Dynamic content not loading from origin server: Dynamic content cannot be cached, so if the origin server is not responding to requests correctly, the page may load slowly or fail to load regardless of CDN caching behavior. Some CDNs — such as Cloudflare's — come integrated with additional services that can accelerate the delivery of dynamic content.

Files not optimized: Very large content pieces or certain file types may not be cached, depending on the limits of the CDN. Make sure all content is optimized for fast delivery and a good user experience. Many CDNs have features for optimizing, "minifying" (reducing the file size), or compressing content.

Render-blocking resources: These are elements of a page that prevent the rest of the page from loading. Cascading style sheet (CSS) files, for instance, are render-blocking resources. If the rest of a page is caching properly but CSS files are not, then the CSS file has to be fetched from the web server before the other page elements can be served from the cache. This can slow down page load times. Make sure render-blocking resources are cached, or rearchitect the page so unnecessary resources are not included or are loaded last.

Third-party scripts not cached: Many websites integrate scripts from other sources; those sources may not use the same CDN. These third-party scripts can take longer to load if their origin servers are far away geographically, not optimized for delivery, or overloaded. If the scripts are render-blocking resources, that can slow down the entire page. Use Chrome developer tools to assess what is loading slowly and where it is coming from. Consider replacing scripts that consistently slow down a page, or using scripts hosted via CDNJS, a free content delivery network that serves thousands of JavaScript and CSS libraries.

CDN cache hit ratio is low: In caching, a "cache miss" means the requested content was not found in the CDN and must be fetched from the origin server. A "cache hit" means the requested content was found in the cache and served from the cache. Cache hit ratio measures the relationship between hits and misses for a given website. A low cache hit ratio means most of the webpage is not being served from the cache, and the user's browser has to get it from the origin server instead. Each cache miss may also incur egress fees for websites, depending on the hosting provider, and the result is higher operational costs for those websites.

Low cache hit ratios can happen for several reasons:

  • Cache rules: Cache rules can determine what is cached and how long it is cached for. If cache rules are not configured correctly, the right content will not be cached. CDN providers should offer a way to troubleshoot caching on specific URLs. (See, for example, Cloudflare Trace).
  • Caching levels: Assets may be cached differently depending on their URL type. Some CDNs can cache the same content by base URL regardless of query strings appended to the URL, or different content for each query string, or regardless of query strings (a query string comes after a question mark in the URL, like "example.com/image.jpg?with=query"). Assets may be delivered differently depending on the query string attached to URLs, and sometimes this is not intended behavior. To fix this issue, adjust caching levels settings.
  • Cache-control headers: Cache-control headers are attached to HTTP responses from origin servers. These headers set caching rules for browsers and for intermediaries like CDNs. Cache-control headers may conflict with caching rules set in the CDN, depending on the provider, so compare them against each other to make sure both are set correctly if one is overriding the other.

Bear in mind that cache hit ratio is not the only metric that matters when it comes to website performance. A holistic view of web performance includes the Core Web Vitals and other metrics that impact the user experience, SEO, and AI optimization.

Outdated content showing on website

If content loads quickly, but it is the wrong content, not reflecting recent updates or changes, the time-to-live (TTL) may be set too high for cached content. TTL is a setting that measures, in seconds, how long a piece of content should be cached before the CDN (or the browser) refreshes its saved copy. Lower the TTL for content that is not updating quickly enough. Alternatively, try clearing the cache so that the CDN will re-fetch content from the origin server.

Content that is updated frequently may need special caching rules. In some cases, it should not be cached at all. Cloudflare has a purge feature that allows content for a webpage to be purged immediately from cache.

DNS configurations

If a domain and all its subdomains are not pointing to the CDN, the content associated with those domains will not be cached and the website will not see any performance benefits.

Make sure subdomains are set up correctly. Subdomains (configured via CNAME record) have to be set up separately. If a subdomain is not behind the CDN — even if the primary domain is — its content will not be cached.

SSL errors with CDN

CDNs often provide SSL certificates for websites. SSL certificates help authenticate the user's connection to the website, encrypt sensitive data entered by the user, and prevent security warnings in the browser for users. But sometimes a website will serve "mixed" content — in which some content on a webpage is served over an SSL connection and some is not. Users may get browser warnings about the security of the page, the page may fail to load, or the page might load more slowly (as the browser tries and fails to initiate TLS handshakes).

These errors may occur if a webpage contains content from external sources or from subdomains that are not listed on the SSL certificate. The Chrome developer console can help developers troubleshoot mixed content errors: Developers can see where content is loading from and what URLs are used.

Other SSL errors may have to do with the domain's certificate. Learn about common SSL issues here.

Need support with the Cloudflare CDN? Join the Cloudflare Community for free support and insights from expert Cloudflare users.

 

FAQs

What is a CDN?

A CDN (content delivery network) is a group of distributed servers that save copies of web content to deliver it quickly to users. Beyond caching, CDNs help accelerate content delivery and improve user experiences through services that support streaming, dynamic content, DDoS mitigation, and TLS usage.

How can a CDN improve website performance?

CDNs help websites load faster for users by sitting between end users and origin servers and accelerating website content delivery. They do this by reducing the distance between users and the content they request, and by optimizing files so that they can be delivered more quickly.

What are some reasons a CDN might perform slowly?

Several issues can cause slow CDN performance, including a lack of global reach, origin server problems, dynamic content not loading correctly, unoptimized files, render-blocking resources, uncached third-party scripts, or a low cache hit ratio.

What is a low cache hit ratio and why does it matter?

A low cache hit ratio means that most of a webpage's content is not being served from the CDN's cache, forcing the user's browser to retrieve it from the origin server instead. Depending on the architecture of the webpage in question, this can lead to slower page load times and potentially higher operational costs due to egress fees.

What causes a low cache hit ratio?

Low cache hit ratios can result from incorrectly configured cache rules, varying caching levels for assets based on URL type (such as query strings), or conflicts between cache-control headers from origin servers and CDN caching rules.

Why might outdated content appear on a website using a CDN?

Outdated content can appear if the Time-To-Live (TTL) setting for cached content is too high. TTL determines how long content is cached before the CDN or browser refreshes its copy. Lowering the TTL or clearing the cache can resolve this.