Override the cache-optimized response headers

Adaptive Media Delivery makes two assumptions in the background so your content caches well: it sets a fixed Content-Type rather than reading one per request, and it strips the Vary header so every client can share a cached object. Both are the right default. Both occasionally break a client that needs the real value.

This use case covers how to put each one back, and what it costs.

When to use this

  • A client or device requires a specific MIME type that doesn't match the fixed value.
  • You serve legacy formats whose Content-Type your players depend on.
  • An application genuinely needs Vary to reach the client — and you accept the caching consequences.

Customize the Content-Type header

When Adaptive Media Delivery recognizes a supported file, it classifies it as a media file based on the Content-Type in the response and applies a fixed value through metadata. That saves reading the header from your origin and generating a per-response header, which would delay delivery by a small amount on every request.

To return something else, add the Modify Outgoing Response Header behavior in a rule.

📘

Not in the default rule set

Modify Outgoing Response Header isn't supported in the default rule set. Each content type needs its own rule.

Set it up

  1. Add a rule from the Blank Rule Template.
  2. Add a match. The supported criteria are File Extension, Filename, Path, Hostname, or Variable Match, with is one of.
  3. Enter the value in Select Items — for example, manifest.m3u8 if you matched on filename.
  4. Add the Modify Outgoing Response Header behavior.
  5. Set Action to Modify and Select Header Name to Content-Type.
  6. In Header Value, enter what the response should carry. For a rule targeting manifest.m3u8, you might return the MIME type for a ts segment, video/mp2t.
  7. Repeat for each content type you need. One content type per rule.

If the file type you want isn't in the Select Items dropdown, type the extension without the leading period. The New Header Value doesn't have to be the format's default MIME type — whatever you enter goes into the response.

Worked example: three content types

Two rules match on file extension; a third matches on a second service hostname used for legacy media. That hostname has to exist as a service hostname in the environment before you can match on it.

  • Primary hostname baseball-videos.com — handles the majority of requests. The first two rules apply here.
  • Secondary hostname baseball-videos-legacy-windows.com — handles specific legacy media.
RuleMatchActionNew Header Value
1File Extension is one of tsModify Content-Typevideo/mp2t
2File Extension is one of m4vModify Content-Typevideo/mp4
3Hostname is one of baseball-videos-legacy-windows.comModify Content-Typevideo/ms-asf

Resulting responses:

Content-Type: video/mp2t        ← request for a .ts segment
Content-Type: video/mp4         ← request for an .m4v file
Content-Type: video/ms-asf      ← request to baseball-videos-legacy-windows.com

Rule 3 covers Windows Advanced Systems Format media — asf, wma, and wmv — which share the video/ms-asf MIME type.

Leave the Default CORS Policy rule alone

Your environment includes a Default CORS Policy rule containing several instances of Modify Outgoing Response Header, pre-populated to optimize delivery. Akamai recommends leaving that rule and its settings as they are. Manage Content-Type in a separate rule, as above.

📘

Existing configurations

Earlier versions of Modify Outgoing Response Header refused to modify Content-Type and returned an error. Create a new version of the configuration to pick up this support.


Let the Vary header through

Many web servers add Vary by default, so applications can alter content based on the browser or other client properties. That makes the object hard to cache — a different client property means a different cached copy. As a best-practice optimization, Adaptive Media Delivery assumes all content is cacheable and removes the Vary header.

To keep it:

  1. Decide the scope.
    • All requests — do the remaining steps in the default rule set.
    • Specific requests — create a rule with the match criteria you need and do the remaining steps there.
  2. Add the Remove Vary Header behavior.
  3. Set the Remove Vary Header slider to Off.

What this costs you

Content is now treated as uncacheable. Adaptive Media Delivery assumes the Vary header carries instructions specific to a client type, so it can't serve one cached object to everyone.

There's one exception: the object can still be cached if the Vary header contains only Accept-Encoding and the Content-Encoding header is br or gzip.

Scope this as narrowly as you can. Turning it off in the default rule set makes your whole catalog uncacheable.

Related


Did this page help you?