Scheme-Based Caching

scheme based caching

Scheme-based caching allows KeyCDN customers to cache both the HTTP and HTTPS version of an asset from the same site. This is useful for websites that may only deliver certain parts of their site (e.g. checkout page) over HTTPS while the rest of the site is delivered over HTTP.

If your site delivers assets both over HTTP and HTTPS you may consider enabling KeyCDN’s Cache Key Scheme feature available in the advanced features section of a pull zone.

How Does Scheme Based Caching Work?

To enable scheme-based caching, navigate to your pull zone’s advanced features section and scroll down to the Cache Key Scheme option. Set this to enabled and save your zone settings (it takes a few minutes for the changes to take effect).

cache key scheme setting

KeyCDN will now start caching both assets which are delivered via HTTP and/or HTTPS. An asset’s scheme can be identified by opening Chrome dev tools, navigating to the Network tab and selecting an asset. Then, under the Request Headers section, the :scheme header and value will be defined, which in the case below, is https.

scheme request header

If your site delivers the same asset over HTTP and HTTPS, enabling the Cache Key Scheme option will allow you to cache the asset for both use-cases. Therefore non-HTTPS visitors will still be able to access the asset from the CDN once it has been cached, and vice-versa. However, enabling this feature will reduce your cache HIT percentage as the edge servers will encounter a MISS if the HTTPS version of an asset is cached but not the HTTP version.

Should You Enable Scheme-Based Caching?

Scheme-based caching should only be enabled in special use-cases. The Internet is moving towards being delivered completely over HTTPS to increase security and speed, therefore it is recommended to migrate all of your HTTP URLs to HTTPS if possible. Moving to HTTPS also allows you to take advantage of the benefits of HTTP/2 and Brotli. Check out our complete guide on migrating from HTTP to HTTPS if you want to learn how to deliver your site completely over HTTPS.

That being said, in the event that you’re using a legacy system or the migration process will be just too time-consuming or costly, enabling the Cache Key Scheme feature will allow you to provide your visitors with faster loading resources over HTTP and HTTPS.

The Cache Key Scheme and Origin Shield feature are not supported to be both enabled.

Related Articles

Leave A Comment?