HTTP/2 Browser Detector using ESI

Document created by Javier Garza Employee on Jun 29, 2016
Version 1Show Document
  • View in full screen mode

I created a simple, and effective HTTP/2 Browser detector using ESI. Basically the code below uses a Header called PROTOCOL_NEGOTIATION (this header gets populated from a dynamic server variable within the Akamai Metadata configuration) which contains the secure protocol negotiated between the Edge server and the client, and depending of it's value show a specific message (if the protocol is h2, then show a button pointing to the HTTP/2 demo).


You can see this ESI code in action here HTTP/2: the Future of the Internet | Akamai (you will need to use an HTTP capable browser like Chrome, Firefox or Opera to see the demo button. Or use Safari to see the not HTTP/2 enabled message)


<!--esi <esi:choose>

    <esi:when test="$(HTTP_PROTOCOL_NEGOTIATION) matches '''h2-14|h2-16|h2'''">

        You are using HTTP/2 right now!<br/><button id="gobutton" type="submit" onclick="window.location = '/demo';" autofocus>Click here for a DEMO</button>


    <esi:when test="$(HTTP_PROTOCOL_NEGOTIATION) matches '''spdy/*'''">

        This browser is not HTTP/2 enabled (but at least supports SPDY). <a href="" target="_blank">(HTTP/2 supported browsers</a>



        This browser is not HTTP/2 enabled. <a href="" target="_blank">HTTP/2 supported browsers</a>





Message was edited by: Javier Garza

This document was generated from the following discussion: HTTP/2 Browser Detector using ESI