Implement HEADER transmission mode for CMCD data
Created by: wilaw
It was assumed that CMCD would always be more efficient to implement via query args, since the use of custom headers required an OPTIONs preflight request to be made to the origin. This is true for media objects requested via discreet GET requests. However, if range requests are used, such as with ondemand addressing in DASH, the the browser makes a new OPTIONS preflight for the range header with each new 'URL'. Since the query rgs are included in the definition of the URL, the browser ends up making a preflight request ahead of every single media sement request as soon as CMCD data is added. This is inefficient.
A solution is for dash.js to offer the HEADER mode of transmission, in which the CMCD data is carried in one of 4 headers (CMCD-Request,CMCD-Object,CMCD-Status,CMCD-Session). The first time these headers are sent, the browser will make a preflight request. This request, if successful, will be cached for the time defined by the Access-Control-Max-Age response header, which is usually longer than the content duration. This results in only one preflight request being made (satisfying the check for both the CMCD and range request headers) which is more efficient than the query arg mode for that ondemand profile.
Specifically, what is requested is
- API to choose the HEADER mode of CMCD transmission. Default can still be query arg.
- Code to package CMCD data in to correct headers and then add it to the outgoing requests.
- Error reporting and log warnings if the Access-Control-Allow-Headers to not give permission for the CMCD headers.
- Log warnings if the Access-Control-Max-Age is not set.
- Log suggestion to use header mode if it is noticed that query args are being used with ondemand profile.