Support for Varnish ESI with Advanced Varnish

Created on 5 February 2025, about 11 hours ago

Problem/Motivation

When using the minify html module in combination with the Advanced Varnish module https://www.drupal.org/project/adv_varnish , the ESI implementation is broken because of the minify html module.

Steps to reproduce

Enable both modules and then enable the minify html and strip comments functionality.

When the output is passed through Varnish using ESI, the minification is gone from the output.
This is because the only allowed reponse classes are:

  • Drupal\big_pipe\Render\BigPipeResponse
  • Drupal\Core\Render\HtmlResponse

The Advanced Varnish module uses "Drupal\adv_varnish\Response\ESIResponse".

Next to that, the output of an ESI tag is provided as

  • <!--esi <esi:include src="..." maxwait="..."/> -->

When stripping comments, we lose this whole section and varnish cannot find the ESI tag anymore. This last one seems like an issue with the module, as it shouldn't need the comment tags, I will report that one there, but keep it here as a reference for people encountering the same issue.

Proposed resolution

To resolve the minification issue it seems that we need to allow to add additional reponse types into the array. I will create a patch to add this specific one right now, but a structural solution needs to be provided to avoid having other contrib modules specific code inside the module.

Remaining tasks

Analyse the best solution, go for a config screen, settings override, hook solution, ... ?

🐛 Bug report
Status

Needs work

Version

2.0

Component

Code

Created by

🇧🇪Belgium hoebekewim

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024