Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ESI includes in JSON response

Tags:

varnish

esi

I'm struggling getting ESI includes to be replaced in a JSON context.

The following working correctly. Resulting in the ESI tag replaced by the actual contents.

<esi:include src="http://domain.com/esipath/" />

And this is not working. The ESI tag isn't replaced.

{
    "test": "<esi:include src="http://domain.com/esipath/" />"
}

I have found some resources on google and a possible solution seems to set esi_syntax to 0x3 for varnish to skip checking for valid XML. This doesn't seem to work on Varnish 4. When I start the deamon with the runtime param I get the following error.

 Error: Unknown parameter "esi_syntax".

Is this setting deprecated in Varnish 4?

Any ideas to get this working?

like image 356
Bram Gerritsen Avatar asked Aug 14 '14 09:08

Bram Gerritsen


1 Answers

indeed that parameter is depricated in varnish4. What you have to do is to activate the feature ESI_DISABLE_XML_CHECK.

For me I edit /etc/default/varnish (debian based system) and add

-p feature=+esi_disable_xml_check

to the DEAMON_OPTS parameters, for example:

DAEMON_OPTS="-a :6081 \
             -T localhost:6082 \
             -f /etc/varnish/default.vcl \
             -S /etc/varnish/secret \
             -s malloc,4GB \
             -p feature=+esi_disable_xml_check"
like image 161
Mirco Blitz Avatar answered Oct 08 '22 04:10

Mirco Blitz