ESI plugin
--------------------

This plugin implements the ESI specification.

Supportted ESI tags:
    esi:include
    esi:remove
    esi:comment
    esi:vars
    esi:choose
    esi:when
    esi:otherwise
    esi:try
    esi:attempt
    esi:except

extended ESI tags:
    esi:special-include

Supported variables:
    $(HTTP_HOST)
    $(HTTP_REFERER)
    $(HTTP_ACCEPT_LANGUAGE{name})
    $(HTTP_COOKIE{name}) or $(HTTP_COOKIE{name;subkey})
    $(QUERY_STRING{name})

  Note: the name is the key name such as "username", "id" etc.
        cookie support sub-name or sub-key, the format is: name;subkey, such as "l;u", "l;t" etc.
           fg. such cookie string: l=u=test&t=1350952328, the value of $(HTTP_COOKIE{"l;u"}) is test
           and the value of $(HTTP_COOKIE{"l;t"}) is 1350952328


Compile and Installation
------------------------

1) Just run "make" in the directory of trafficserver/plugins/experimental/esi/

2) Copy trafficserver/plugins/experimental/esi/.libs/esi.* to /usr/local/libexec/trafficserver/

3) Copy trafficserver/plugins/experimental/esi/.libs/libesi.* to /usr/local/lib/

Enabling ESI
------------

1) First we need to set up /usr/local/etc/trafficserver/plugin.config and make sure the following line is present

esi.so

There are three options you can add. 
  "--private-response" will add private cache control and expires header to the processed ESI document. 
  "--packed-node-support" will enable the support for using packed node, which will improve the performance of parsing cached ESI document. 
  "--disable-gzip-output" will disable gzipped output, which will NOT gzip the output anyway.

2) We need a mapping for origin server response that contains the ESI markup. Assume that the ATS server is abc.com. And your origin server is xyz.com and the response containing ESI markup is http://xyz.com/esi.php. We will need the following line in /usr/local/etc/trafficserver/remap.config

map http://abc.com/esi.php http://xyz.com/esi.php

3) Your response should contain ESI markup and a response header of .X-Esi: 1'. e.g. using PHP,

<?php   header('X-Esi: 1'); ?>
<html>
<body>
Hello, <esi:include src="http://abc.com/date.php"/>
</body>
</html>

4) You will need a mapping for the src of the ESI include in remap.config if it is not already present.

map http://abc.com/date.php http://xyz.com/date.php

Or if both your ESI response and the ESI include comes from the same origin server, you can have the following line in remap.config instead to replace separate map rules for date.php and esi.php

map http://abc.com/ http://xyz.com/

5) Here is a sample PHP for date.php

<?php
  header ("Cache-control: no-cache");
  echo date('l jS \of F Y h:i:s A');
?>

Useful Note
-----------

1) You can provide proper cache control header and the ESI response and ESI include response can be cached separately. It is extremely useful for rendering page with multiple modules. The page layout can be a ESI response with multiple ESI include, each for different module. The page layour ESI response can be cached and each individual ESI include can also be cached with different duration. 

2) You might want to compile the code without using ESI_PACKED_NODE_SUPPORT because it may not work in some corner cases

Differences from Spec - http://www.w3.org/TR/esi-lang
-----------------------------------------------------

1) <esi:include> does not support "alt" and "onerror" attributes

2) <esi:inline> is not supported

3) You cannot have <esi:try> inside another <esi:try>

4) HTTP_USER_AGENT variable is not supported

5) <!--esi .. --> is not supported

6) HTTP_COOKIE supports fetching for sub-key
