Nexcess Logo

Manage your Edge CDN's cache and website expiry date values

Knowledge Base Home

Notice anything different?

We've enhanced the appearance of our portal and we're working on updating screenshots. Things might look different, but the functionality remains the same.
February 06, 2024

Managing the cache and website expiry date values for your content delivery network (CDN) is essential for boosting your website's overall speed. And in modern times, face it, only quick-loading webpages get a significant number of pageviews.

Therefore, adding effective caching policies and rules is a crucial part of creating a well-optimized website. As part of this effort, managing the Edge network for your CDN with Nexcess or the one offered by your web hosting provider should be a priority. In most cases, the CDN provider can be selected independently from the web host and configured to interoperate with your website. The guidelines in this article can be applied to those use cases as well as the use case of when your hosting and CDN providers are the same entity.

As a web hosting company with decades of experience, we love to help our customers build winning websites. The CDN is always a focus of our attention and care. When it comes to engineering all aspects of websites that have an impact in their industries and communities, the CDN can never be ignored.

Key takeaways in this article

The main thoughts you will leave with after reading this article include:

  • Comprehending how a CDN operates with regard to its purpose and value.
  • Having an excellent grasp of Edge cache expiration dates and management strategies.
  • Knowing how to increase website performance by optimizing content expiration dates.
  • Understanding the nuances of the website expiry date values in the context of the Edge CDN.
  • Realizing that you need to find the balance between the website's content freshness and the fastest webpage-loading performance.
  • Mastering the data points, elements, and values involved with caching settings, including those used in Edge Cache TTL and Browser Cache TTL management.
  • Constructing caching rules with customized expression logic, honed criteria, fields, values, and operators.
  • Considering what a good cache hit ratio is — and how to achieve it.
  • Realizing the need for cache purges along with cache-related website metrics monitoring.
  • Taking a proactive approach to website expiry date management for the Edge CDN — including ongoing adjustments.

Edge cache expiration dates and management strategies

The website expiry date determines how long the content will remain on the website before it refreshes. So, it is important to know how to set the expiration date to increase website performance.

  • CDN-provided tools. The tools provided by the CDN providers, including Cloudflare and others can be used to manage the website expiry date of the Edge caches.
  • Static contents. The files like those for JavaScript (JS) and Cascading Style Sheets (CSS) usually change very infrequently. So, these static files can be given longer expiration dates in your caching system.
  • Versioning. You can use this technique to automatically refresh the various files and assets if there are any changes to them.
  • Caching frequencies. Using the correct CDN you can easily alter the expiration dates and caching policies based on the content and make decisions based on it.

Finding the balance between the website's data freshness and the performance

Website expiry dates in Edge caching tell us how long the cached content artifact is allowed to be cached in the CDN before it gets refreshed. There are many ways in which this caching can be done. The most common strategy is to cache the static and readily available contents from the Edge servers instead of re-requesting that content from the origin server again and again.

The freshness of the content needs to be maintained because if we provide a far-into-the-future website expiry date, then the latest data won’t be visible to the users. All things considered, there must be a balance between the website data quality and freshness and the performance of the website's page-loading speeds.

What does TTL mean in CDN caching?

Our partners at Cloudflare define TTL as the following:

Time to Live (TTL) refers to the amount of time or "hops" that a packet is set to exist inside a network before being discarded by a router. TTL is also used in other contexts including CDN caching and DNS caching.

Knowing how to manage TTL values will be of paramount importance when it comes to devising a successful caching methodology. Let's take a deeper look managing both Edge Cache and Browser Cache TTLs further down in this article.

How to manage the website expiry date policies for your CDN

There are various methods for managing the website expiry date:

  • Maximizing the use of caching rules. Implement cache policies based on the content types and the frequency with which you update the data.
  • Upon changes to contents. You can implement techniques that will automatically refresh the cached content when changes are made to the static contents like the Hypertext Markup Language (HTML), JavaScript (JS), and Cascading Style Sheets (CSS) files, etc.
  • Studying content change patterns. Monitor your website regularly. By monitoring the website consistently and analyzing content change patterns, you can quickly devise caching policies that will help in optimizing your website performance. They will need to be tweaked as your content change patterns evolve.
  • Mastering the CDN's caching features. CDN has built-in caching tools that will help you manage and set expiration times for the many content types found on your website. Every CDN has a cache management system. You can find built-in caching tools in all popular CDN platforms like Cloudflare, Amazon CloudFront, and Microsoft Azure CDN, for example. Usually, the cache management option is called caching or page rules in the user interface. The cache management feature set and the number of rules you are allowed to have may vary based your product price plan tier. The plans with the most robust features will include cache rules, cache purging options, Edge Cache TTL values, and Browser Cache TTL settings — among many others.

How does the content delivery network (CDN) work?

CDN is called the content delivery network. A CDN improves the load time for many users by caching the site's original content and re-providing the static content. the CDN is used to serve content to users all around the world by leveraging Edge network servers. Here are some helpful resources for learning more about CDNs:

Geography is the main variable to optimize for — based on the page-loading performance and the shortest network distance when serving web content. For a more detailed understanding of CDN see the How does a CDN work to speed up your website? post.

Managing the website expiry date rules for the Edge CDN's cache

Consider the market leading CDN solution from Cloudflare, which is quite famous. In Cloudflare's CDN platform, each website has a built-in option for optimizing the caching performed. The associated features will help us formulate tailored policies for the website expiry date values.

While establishing your cache rules, there will be a good number of fields available. They are meant to allow you flexibility during construction of the logic involved using Expression Builder, including:

  • Cookie
  • Hostname
  • Referrer
  • URI Full Path
  • User Agent

There are more fields than those listed above. These are the values for which a cache rule can be created. The corresponding cache rule will be executed when an HTTP request is made matching the criteria in the logic of the rule. So, for example, we can set the website expiry date of the cache when it matches a particular Referrer or Hostname, etc.

Edge Cache TTL

Edge Cache TTL — or Time to Live — refers to the duration for which content remains stored in the cache. CDNs such as Cloudflare provide the ability to configure TTL for various file types like HTML, CSS, and JS files. By adjusting the TTL for specific files, you can control how frequently the cache is refreshed and how long each file persists in it.

How to set Edge Cache TTL?

In this example, we are using Cloudflare CDN value for setting the Edge Cace TTL, but the same values can be provided to different CDN providers as well. It can be done in the following way If you want to customize the TTL of different files. The most effective way is to add a key-value pair to the metadata. This method is the most effective and helps you set the TTL for different files. There are different time options for Edge Cache TTLs. A TTL value can range from 0-255 — as it is an 8-bit field:

  • 60 seconds
  • 10 minutes
  • 60 minutes
  • 1 day
  • 1 week
  • Custom

We need to provide a max-age key value pair to cache the website contents. So, based on the value, the caching system will manage the duration of the contents present in the cache.

Browser Cache TTL

Browser Cache TTL is nothing more than how long the users can store the cache in the browser. These cache settings can be determined inside the CDN based on the update frequency for the content type.

About the paid Browser Cache TTL management feature from Cloudflare

With the right product plan purchased directly from Cloudflare or your CDN provider, you can control browser caching from settings from the Edge CDN. These custom settings for the Browser Cache TTL would be configured as part of a page rule. However, this advanced feature is not available on free plans with Cloudflare. So, if desired, you should acquire a paid plan with this useful feature.

Cloudflare allows you to set the Browser Cache TTL anywhere from two minutes all the way up to one year within a Cloudflare Page Rule if you have the appropriate functionality available in your product. Please note that Nexcess does not offer that level of control from the Performance Shield product at the time this article was published.

Page rules for caching

While using CDNs like Cloudflare, Amazon CloudFront, and Microsoft Azure CDN there are options currently to add page rules for caching. Basically, a page rule allows us to provide specific cache-handling rules for particular URLs or website paths:

While using CDNs like Cloudflare, Amazon CloudFront, and Microsoft Azure CDN there are options currently to add page rules for caching. Basically, a page rule allows us to provide specific caching rules for specific URLs or website paths.

Suppose you have an ecommerce website, and you want to make sure that you want to optimize that page by caching the contents on that page. In this kind of scenario, what you can do is you can apply a simple page-level caching rule to cache all the static assets on the page. This configuration will help you in optimizing the loading time for the webpage.

In the Cloudflare example that follows, the starting point would be the caching area of Cloudflare Dashboard. It is where you will create, manage, and edit your caching ruleset:

In the Cloudflare example that follows, the starting point would be the caching area of Cloudflare Dashboard. It is where you will create, manage, and edit your cache rules.

When creating a new cache rule, we need to provide a rule name and give the specific rule logic to follow with the corresponding field names. When building expressions you can use various operators for rule flexibility, including:

  • equals
  • does not equal
  • contains
  • matches

These can be further refined with logical operators, including:

  • and
  • or
  • not
  • xor

There are more options than those listed above.

A note about the future of Cloudflare Page Rules

It is noteworthy to mention here that a new caching rules architecture is in the works where Cloudflare will replace its Page Rule product feature with the following kinds of rules:

1. Cache Rules: A dedicated product for setting and tuning 'everything caching’.

2. Configuration Rules: A dedicated product for setting and selectively enabling, disabling and overriding zone-wide settings.

3. Dynamic Redirects: Like ‘Forwarding URL’ but turned up to 11. Redirect based on the
visitor's country, their preferred language, their device type, use regular expressions (plan-level dependent) and more.

4. Origin Rules: A dedicated product for ‘where does this traffic go where it leaves Cloudflare. Not only have we added host header and resolve override into this new product, we’ve also productized another common Workers use case by enabling customers to selectively override the destination port. We’ve also added the ability to override the Server Name Indication (SNI).

Purging the CDN

CDN purge is the method where the current static files in the cache are removed, and new files are generated on request by the users. a CDN purge is essential to remove the current static files in the cache. You can learn more in our What does purge the CDN mean? Purging the Nexcess CDN article on the topic.

Monitoring and analytics

Monitoring is one of the significant activities involved with the configuration of successful Edge caching. All the major CDN platforms have tracking and analytics to report the number cache hits and cache misses:

What is a CDN cache hit? What is a cache miss?

A cache hit is when a client device makes a request to the cache for content, and the cache has that content saved. A cache miss occurs when the cache does not have the requested content.

A cache hit means that the content will be able to load much more quickly, since the CDN can immediately deliver it to the end user. In the case of a cache miss, a CDN server will pass the request along to the origin server, then cache the content once the origin server responds, so that subsequent requests will result in a cache hit.

So, the cache hit ratio is the sum of the number of cache hits fulfilled divided by the sum of cache hits fulfilled plus the number of missed cache hits. In general, a cache hit ratio must have a higher value for the website to perform well in terms of speed gained from cache utilization.

For example, on your website, the CDN has a cache hit number of 53 number and a cache miss number of 10. The cache hit ratio is calculated using the following formula:

53/53+10 = 0.84 (84%)

After doing the cache hit ratio analysis, it is best to ensure that your CDN's caching rules are facilitating a high cache hit number for a particular website. The higher your percentage value for the cache hit ratio, the better your website’s page-loading performance will be. In line with this logic, by assessing the cache hit and cache miss numbers, we can easily manage our cache policies and make the corresponding decisions and adjustments.

Regarding having a good cache hit ratio, according the Cloudflare website, a percentage above 90% would be an excellent goal:

What is a good CDN cache hit ratio for most websites?

A typical website that's mostly made up of static content could easily have a cache hit ratio in the 95-99% range. However, getting this metric as high as possible isn't the only goal of a CDN. Additionally, a website with lots of dynamic content may have a much lower cache hit ratio (although caching dynamic content is becoming possible).

Why to proactively manage the website expiry date for your Edge CDN

For an ecommerce website to experience success, the products, images, and all other elements need render in the blink of an eye, ideally, So, having a full page and object cache working as expected in conjunction with having an efficiently designed Edge CDN caching system in place are vital.

Learn about our Edge CDN — configured specifically for Nexcess customers

Speed up your site worldwide with data served from 285 cities at no additional cost.

Advanced caching prioritizes your most frequently accessed files, making every site visit as fast as possible.

The key consideration when proactively managing caches within your Edge network for the CDN is to maintain the website's rendering performance with thought-out and well-crafted caching rules that do omit valuable content changes that occur.

You want to run a website to maintain the speed and accessibility for all visitors — even those with slow connections. However, with your caching decisions, the tradeoff will always be the integrity of your content in terms of its accuracy and freshness, which should be evaluated by content category. Then, these TTL settings should be reviewed on a recurring basis to maintain the optimal experience for your site visitors.

Akshay Sunil
We use cookies to understand how you interact with our site, to personalize and streamline your experience, and to tailor advertising. By continuing to use our site, you accept our use of cookies and accept our Privacy Policy.