Headers that are a must have when dynamically retrieving assets

Document created by B-F-F08DRX Employee on Oct 23, 2017Last modified by Salvador Camacho Reyes on Dec 14, 2017
Version 2Show Document
  • View in full screen mode

Edited on October 16, 2015:


As of SOASTA 55.18 (build 8023.259) released on September 18, 2015, the headers "Connection:keep-alive" and "Accept-Encoding: gzip, deflate, sdch" are being passed from the Main HTML Doc of the page to the resources. This is provided that the Main HTML Doc has them. If they are not present, they won't be passed and you'll need to add them manually to the Main HTML Doc of the page in order for them to be propagated to the resources.


So now the headers passed from the Main HTML doc to the resources are: Host, Cookie, User-Agent, Connection:keep-alive and Accept-Encoding: gzip, deflate, sdch.


So no need to add the JavaScript in this post unless you are adding dynamic resources via a JavaScript.


This is still true: Whatever is set at the Target level headers doesn't get added to the dynamic requests' headers.


Please read the below article for more important information on headers now that they are being passed from the Main HTML Doc:


Important Things to know about headers for dynamic resources


I am leaving the below intact since some things still apply and the JavaScript should be used when setting the dynamic resources via a JavaScript, described in the link in the article above.




If you are getting Connection resets in the assets it is most probably due to the missing header "Connection: keep-alive". Also for Akamai and just in general it is good to add the header "Accept-Encoding: gzip, deflate, sdch". This last one when not present leads to the server sending uncompressed responses and thus taking longer since the content lenght is bigger than when sending this header.


I am attaching the JavaScript that takes care of this. The JavaScript needs to be added just after each of the main HTML Document of each page that is dynamically retrieving assets.


Below is the text version of it:


// This JavaScript will add the different akamai headers to the dynamic resources.
// this is needed since the only headers transferred from the parent are Host, Cookie and User-Agent.
// The above is still true on Jul 19, 2013, but it might change in the future
var headers = $context.currentPage.dynamicResourceHeaders;
if (headers == null)
   headers = "Accept-Encoding: gzip, deflate, sdch";
   headers += "\nConnection: keep-alive";
   headers += "\nAccept-Encoding: gzip, deflate, sdch";
   headers += "\nConnection: keep-alive";

// Setting Akamai headers - For triaging - Uncomment if needed
// IMPORTANT: Akamai pragma headers should be in a single header line as below, if you need to add more pragma headers separate them with a comma
// headers += "\nPragma: no-cache, akamai-x-cache-on, akamai-x-cache-remote-on,akamai-x-check-cacheable, akamai-x-get-cache-key, akamai-x-get-true-cache-key,akamai-x-get-extracted-values, akamai-x-get-ssl-client-session-id, akamai-x-serial-no, akamai-x-get-request-id";

//  Setting the new header to dynamic resources if it was modified
$context.currentPage.dynamicResourceHeaders = headers;