Discourse stripping ESI tag when adding custom footer

We use Varnish to serve a common header and footer for our site using ESI tags. These look something like:

<esi:include src="http://www.xyz.abc/esi_parts/footer" />

When discourse serveres the page back to Varnish it will inject the content into the page. However when we customize our theme (using the editor within the admin panel) and add the line above to the footer then on page load we see in the page source that its converted the above to:

<include src="http://www.xyz.abc/esi_parts/footer"></include>

Or sometimes (it seems random) it doesn’t show up in the page source at all.

Is there some parser that is mangling/removing it and if so how can we disable it or workaround it?

This is going to be too late, footer is dynamically added so any mangling your varnish wants to do will happen too late.

You are going to have to figure out a different solution here.

2 Likes

Thanks but how is that possible since Varnish sits in front of Discourse and serves the page to the browser. So varnish requests the page from Discourse and once received it can cache it if necessary and also inject ESI’s and other things. How can discourse prevent that? (other than by refusing to allow the esi:include tag in the markup)

The footer is passed to the SPA as a JSON blob.

https://github.com/discourse/discourse/blob/574d447254ea4cddc2c9818ca952ecdb9b3b5532/app/controllers/application_controller.rb#L502-L514

So unless you teach varnish how to fiddle with the json you are not going to have any luck there.

3 Likes

Ah got it, thanks Sam!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.