![Barniz ESI no funciona](https://rvso.com/image/617238/Barniz%20ESI%20no%20funciona.png)
Tengo una configuración como esta: - puerto nginx 80 - puerto de barniz (3.0.4) 6081 - puerto apache 8080
Nginx toma la solicitud y la pasa a Varnish, quien luego verifica el caché y luego devuelve la respuesta del caché o pasa la solicitud a Apache. En Apache, deshabilité mod_deflate para que la salida no esté comprimida. Dentro de Varnish, habilité ESI para todas las solicitudes como esta:
sub vcl_fetch {
set beresp.do_esi = true;
}
Y mi archivo de prueba (test.php) se ve así:
Current time is: <esi:include src="/date.php" />
La fecha.php:
<?php
echo date('H:i:s');
Pero Varnish no procesa el esi incluido. En barnizlog me sale este error:
11 ESI_xmlerror c No ESI processing, first char not '<'
Encabezados de respuesta de test.php:
Accept-Ranges:bytes
Age:3
Connection:keep-alive
Content-Length:51
Content-Type:text/html
Date:Sun, 01 Sep 2013 11:51:57 GMT
Server:nginx
Surrogate-Control:"ESI/1.0"
Via:1.1 varnish
X-Powered-By:PHP/5.4.15-1~precise+1
X-Varnish:1236304062 1236304061
Y la salida html:
Current time is: <esi:include src="/name.php" />
Entonces puedes ver que ESI no se procesa.
¿Qué estoy haciendo mal?
Respuesta1
Lo solucioné... si el primer carácter de la respuesta del servidor no es "<" ESI no funcionará. La solución para mi problema fue simplemente envolver el archivo de prueba en una estructura HTML estándar, para que se vea así:
<html>
<head>
<title></title>
</head>
<body>
Current time is: <esi:include src="/name.php" />
</body>
</html>
Respuesta2
Otra forma es ejecutar el demonio Varnish con el parámetro:
-p esi_syntax 0x3
lo que significa
0x00000001 - Don't check if it looks like XML
0x00000002 - Ignore non-esi elements