Prefetch Headers

Unified Origin will dynamically generate HTTP Link headers [1] for Smooth Streaming media segments, if possible. From these headers, you can optionally derive other headers which assist with prefetching content.

For example, a Smooth Streaming request to Unified Origin for /presentation.ism/QualityLevels(652000)/Fragments(video=0) automatically generates a (relative) HTTP Link header pointing to the following media segment:

Link: <Fragments(video=4800000)>; rel="next"

Unified Origin 1.10.35 and later now also generate this header for other types of media segments:

  • DASH media segments, numbered and timeline-based (.dash, .m4s)

  • HLS media segments (.ts)

  • AAC, AC3, AC4 and EC3 audio segments (.aac, .ac3, .ac4 and .ec3)

  • Smooth Streaming segments, a.k.a. ismv or isma (QualityLevels(XXX)/Fragments(video=Y))

  • Flash media segments, a.k.a. F4F (-SegX-FragY)

  • SMPTE-TT subtitle segments (.smptett)

  • WebVTT subtitle segments (.webvtt)

With Apache, the Link headers can be also used to conditionally set the Akamai CDN-Origin-Assist-Prefetch-Path headers [2]. These should only be set when the request contains a CDN-Origin-Assist-Prefetch-Enabled: 1 header.

For this to work, at least Apache 2.4.10 is required, and mod_headers should be enabled. A configuration section like the following can then be added to the desired VirtualHost section:

<Location "/my/media/location/">
  # Set Akamai prefetch response header from the Link header, in two phases:
  # * If the request has a CDN-Origin-Assist-Prefetch-Enabled header, copy contents of the Link: header, if it exists and has the right format
  # * Extract the actual link from the <xxxx>; rel="next" expression
  Header set  CDN-Origin-Assist-Prefetch-Path "expr=%{resp:Link}" "expr=%{req_novary:CDN-Origin-Assist-Prefetch-Enabled} == 1 && %{resp:Link} =~ /<([^>]+)>; rel=\"next\"/"
  Header edit CDN-Origin-Assist-Prefetch-Path "<([^>]+)>; rel=\"next\"" "$1"
</Location>

This would only add a CDN-Origin-Assist-Prefetch-Path response header, if the request has a CDN-Origin-Assist-Prefetch-Enabled: 1 header, and the response has a Link header in the expected format (e.g. Link: <relative_url>; rel="next").

Note

The above directives only work on Apache 2.4.10 and later. Most Linux distributions come with newer versions, but a notable exception is CentOS/RHEL 7, which unfortunately has Apache 2.4.6. So the above example configuration will not work on CentOS/RHEL 7, resulting in a syntax error during Apache startup.