What You Need to Know About Caching – Part 3

by Mario Korf
1828

We hope you watched the first and second videos in this series. Tedd and CJ (and the squirrel) are back to talk about cache keys: what they are, how to define them, and some advanced optimization.

Transcript follows, natch.

Transcript

Welcome back! I’m Tedd Smith, a Solutions Engineer at Akamai. This is the third episode in our video series on caching and we’re going to go a step further into the technical details of how to best configure a few things.

Today we’ll cover:

  • What a cache key is
  • How it impacts caching and how to best define it
  • And finally advanced cache optimization

Cache Keys

First let’s introduce the concept of Cache Keys. A cache key is a unique string that lets Akamai edge servers look for your content when requests hit them. It’s made up of a few different pieces (like origin hostname, path, and filename).

If you’re familiar with databases, think of this as the primary key we would use to find your files in our cache. Or, if you’re a squirrel, think of this as the color, smell, and shape which would help us identify the right acorn for you!

Selecting the correct cache key will ensure maximum cache footprint and increase cache hits.

Configuring Cache Keys in Akamai

Configurations in the Luna portal have a few options for selecting the right cache key. Let’s look at them here. The Origin behavior is your primary location where you set the cache key. You can select either Origin Hostname or Incoming Host Header. Two examples can illustrate why you would choose one vs the other:

  • First, let’s say you have localized sites that serve different languages, using different hostnames but the same file structure. While you might put all these hostnames under one delivery configuration, the same file path would need to cache unique content appropriately. You’d want to set the Cache Key to Incoming Host Header. This will ensure Akamai edge servers treat a file such as banner.png differently for each of these domains
  • Now let’s say you have multiple hostnames that all serve the same exact content. You might be doing this for domain-sharding reasons or simply because you have multiple online properties that serve similar content. In this example you would want to set the Cache Key to Origin Hostname, so Akamai edge servers treat all objects under these hostnames the same and only cache ONE copy of each file.

There’s also an included feature to specify whether the URL case (upper or lower) should be honored or ignored in the cache key.

 How Query Parameters Affect Cache Keys

Next, let’s take a look at how query parameters might affect your cache key. If your URLs use query parameters you have the option to include or exclude them in your cache key.

If the query parameter doesn’t actually indicate that the contents of the file need to be different (for example they’re merely passing in user or device data) then you’d want to EXCLUDE them from the cache key. Akamai will cache a single copy of this file and serve it out regardless of what the query parameters indicate. Additionally you can choose to only exclude certain query parameters.

However, another use case might be using the query parameters to add version data to a request. In this case you’d want to INCLUDE them in the Cache Key. You can go further and choose to include all of them as they’re indicated in the incoming URL, or reorder them alphabetically, or only include certain parameters.

If you thought this was a lot of control over how content gets cached, hang on to your seats, there’s even more!

Advanced Cache Control

Akamai allows many different ways of controlling cache behavior to allow powerful and creative configurations.

The Cache ID Modification behavior (only available with the inclusion of Advanced Cache Optimization module) takes the cache control options for setting the cache key beyond just path, filename, and query parameters by adding header or cookie values to the mix.

This behavior allows the value of any specific header or cookie to be added to the cache key. A good example would be using the Accept-Language header to cache different versions of a single URL that’s been localized.

Conclusion

Now that you’ve seen all the different ways cache keys can be modified with Akamai, you have a powerful tool at your fingertips to maximize your cache affinity and ensure content is served as best as possible out of the Akamai network.

As always, please reach out to your Akamai account team for the best guidance on utilizing any of these caching features. They have the best perspective to help you in relation to your specific use case.

Categories: Technology, Video

Suggested Article

LEAVE A REPLY