ESI include: src, alt, onerror weirdness

Florian Gilcher varnish-lists at andersground.net
Wed Feb 11 14:14:22 CET 2009


Hi,

being rather new to using varnish, I don't want to file this as a bug  
right away.

First of all, my .vcl in use:

===
backend www {
   .host = "127.0.0.1";
   .port = "4567";
}

sub vcl_fetch {
     esi;
}
===

I have two problems. I have an include-element of the following form:

===
<!-- head and everything -->
   <body>
     <esi:include src="/include" alt="/alt" onerror="continue" />
   </body>
</html>
===

First, I (accidentally) forged "/include" to return 404 and no body,  
which leads to the following output:

===
<!-- head and everything -->
   <body>
===

So, the ESI processing stops in the moment that the include is empty  
string.

The scenario second problem is as follows:
1. "/include" returns 404 and the string "some text" as body.
2. "/alt" returns 500 and the string "some other text" as body.

Reading the (rather unspecific) ESI Language Specification, I expect  
that the include-element is deleted silently, because:

1. "src" "is not found".
2. "ESI can fetch neither the src nor the alt"

So, I would expect:

===
<!-- head and everything -->
   <body>
   </body>
</html>
===

But, much to my surprise, the return is:

===
<!-- head and everything -->
   <body>
     some text
   </body>
</html>
===

It also happens if "/include" returns 500. I checked the headers, they  
are okay. It happens both with 2.0.2 and trunk, OS is Gentoo Linux and  
OS X.

So, I am beginning to wonder on how esi:include is implemented in  
varnish or what I am doing wrong. Because - granted - the ESI  
specification could be interpreted to include the element without  
giving much thought on what the returned entity actually represents.  
Then this would be the correct behaviour, as the backend is obviously  
responding.

To potentially save you some work, i'll include my demo script (in  
ruby/sinatra) and the vcl below.

Thank you for your time,
Florian Gilcher

--

esi.rb:
===
#!/usr/bin/env ruby

# to use this, you need ruby, configured with zlib and rubygems  
installed
# to install sinatra, run "gem install sinatra"

require 'rubygems'
require 'sinatra'

get '/include' do
   response.status = 500

   "some text"
end

get '/alt' do
   response.status = 500

   "some other text"
end

get '/' do
   '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
     "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

   <html>
     <head>
       <meta http-equiv="Content-type" content="text/html;  
charset=utf-8">
       <title>Page Title</title>
     </head>
     <body>
       <esi:include src="/include" alt="/alt" onerror="continue" />
     </body>
   </html>'
end
===

esi.vcl
===
backend www {
   .host = "127.0.0.1";
   .port = "4567";
}

sub vcl_fetch {
     esi;
}
===




More information about the varnish-misc mailing list