Search code examples
phpvarnishesi

Varnish ESI: strange characters


I'm having a problem with Varnish ESI (Edge Side Includes): sometimes the part which uses ESI displays strange characters, like the ones of image below:

The part with ESI sometimes displays strange characters

How can I fix this? The funny part is that sometimes this problem occurs, but sometimes not.


Solution

  • This looks like a strange bug with gzip in Varnish. If you get gzipped block trough ESI and it is not in cache (MISS) you get this strange symbols. If you get this block from cache everything is ok. The solution is to disable gzip for internal routes:

    if (req.url ~ "/_internal") {
        # Telling ESI that we do not support gzip
        remove req.http.Accept-Encoding;
    

    .....