6
*Edge Side Includes* is a language to include *fragments* of web pages
7
in other web pages. Think of it as HTML include statement that works
10
On most web sites a lot of content is shared between
11
pages. Regenerating this content for every page view is wasteful and
12
ESI tries to address that letting you decide the cache policy for
13
each fragment individually.
15
In Varnish we've only implemented a small subset of ESI. As of 2.1 we
16
have three ESI statements:
22
Content substitution based on variables and cookies is not implemented
23
but is on the roadmap.
28
Lets see an example how this could be used. This simple cgi script
33
echo 'Content-type: text/html'
35
date "+%Y-%m-%d %H:%M"
37
Now, lets have an HTML file that has an ESI include statement:::
41
The time is: <esi:include src="/cgi-bin/date.cgi"/>
46
For ESI to work you need to activate ESI processing in VCL, like this:::
49
if (req.url == "/test.html") {
50
set beresp.do_esi = true; /* Do ESI processing */
51
set beresp.ttl = 24 h; /* Sets the TTL on the HTML above */
52
} elseif (req.url == "/cgi-bin/date.cgi") {
53
set beresp.ttl = 1m; /* Sets a one minute TTL on */
54
/* the included object */
61
The *remove* keyword allows you to remove output. You can use this to make
62
a fall back of sorts, when ESI is not available, like this:::
64
<esi:include src="http://www.example.com/ad.html"/>
66
<a href="http://www.example.com">www.example.com</a>
69
Example: <!--esi ... -->
70
~~~~~~~~~~~~~~~~~~~~~~~~
73
This is a special construct to allow HTML marked up with ESI to render
74
without processing. ESI Processors will remove the start ("<!--esi")
75
and end ("-->") when the page is processed, while still processing the
76
contents. If the page is not processed, it will remain, becoming an
77
HTML/XML comment tag. For example::
80
<p>Warning: ESI Disabled!</p>
83
This assures that the ESI markup will not interfere with the rendering
84
of the final HTML if not processed.