清漆 ESI 认可但不包括在内

发布于 2024-10-08 20:08:33 字数 1877 浏览 2 评论 0原文

嘿大家。我在 Varnish 上使用 Edge Side Includes 来缓存静态 HTML shell,然后包含一些动态 HTML 和 JSON 对象。

HTML 的 ESI 已正确包含,但 JSON 对象的 ESI 未包含;调试语句表明 Varnish 可以看到它,但它莫名其妙地决定不包含 JSON ESI。

这是加载结构: <代码>

page uncached. blank page with headers to set a cookie and esi 1
esi 1 cached. A bunch of static HTML, plus esi 2 and esi 3
esi 2 uncached. A JSON object which is different on every page load.
esi 3 uncached. Some HTML which updates with every page load.

同样,esi 1esi 3 工作得很好,但 esi 2 没有包含在内。 esi 2 的内容就是这样:


{session_page_history_id:24231}

我读到看起来不像 XML 的 ESI 代码会导致错误,所以我设置了运行时参数 esi_syntax=0x7 。没有骰子,但至少我现在得到了一些调试数据。

esi 2 的中断调用如下所示:


<esi:include src="http://www.domain.com/dynamic_esi/print_variables?esi__desired_var_names[]=session_page_history_id&for_esi=1"/>

esi 3 的(工作)调用如下所示:


<esi:include src="http://www.domain.com/dynamic_esi/get_service_magic_html?&for_esi=1"/>

正如我提到的,Varnish 似乎认识到我正在尝试使 ESI 包含,但这是我从 varnishlog 获得的唯一相关调试消息:


   25 Debug        c AddBit: 6997 <<![CDATA[

window.esi__values =

<esi:include src="http://www.domain.com/dynamic_esi/print_variables?esi__desired_var_names[]=session_page_history_id&for_esi=1"/>
;

 //]]>
 </script>
 <link rel="stylesheet" href="http://www.

客户端看到的输出包含所有正常内容,但带有标签完好无损。它看起来就像您在上面的调试消息中看到的一样。

有谁知道为什么 esi 2 没有被解析/包含?任何帮助将不胜感激!

Hey everybody. I'm using Edge Side Includes on Varnish to cache a static HTML shell, then include some dynamic HTML and a JSON object.

The ESI for HTML is getting included properly, but the ESI for the JSON object is not being included; Debug statements establish that Varnish sees it, but it inexplicably decides not to include the JSON ESI.

Here's the loading structure:

page uncached. blank page with headers to set a cookie and esi 1
esi 1 cached. A bunch of static HTML, plus esi 2 and esi 3
esi 2 uncached. A JSON object which is different on every page load.
esi 3 uncached. Some HTML which updates with every page load.

Again, esi 1 and esi 3 work just fine, but esi 2 is not getting included. The content at esi 2 is just this:


{session_page_history_id:24231}

I read that ESI code which doesn't look like XML causes errors, so I set the runtime parameter esi_syntax=0x7 . No dice, but at least I'm getting some debug data now.

The broken call for esi 2 looks like this:


<esi:include src="http://www.domain.com/dynamic_esi/print_variables?esi__desired_var_names[]=session_page_history_id&for_esi=1"/>

And the (working) call for esi 3 looks like this:


<esi:include src="http://www.domain.com/dynamic_esi/get_service_magic_html?&for_esi=1"/>

As I mentioned, Varnish appears to recognize that I'm trying to make an ESI include, but this is the only relevant Debug message I get from varnishlog:


   25 Debug        c AddBit: 6997 <<![CDATA[

window.esi__values =

<esi:include src="http://www.domain.com/dynamic_esi/print_variables?esi__desired_var_names[]=session_page_history_id&for_esi=1"/>
;

 //]]>
 </script>
 <link rel="stylesheet" href="http://www.

The output seen by a client contains all the normal content, but with the <esi> tag left intact. It looks just like what you see in the above Debug message.

Does anyone know why esi 2 isn't getting parsed/included? Any help would be GREATLY appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

原谅过去的我 2024-10-15 20:08:33

显然,ESI 标记没有得到处理,因为它位于 //[CDATA[ 块内。我确信这与 XML 合规性有关。我认为设置 esi_syntax=7 可以防止这样的问题,但事实证明这只会影响 ESI 本身的内容(它不会解除对执行包含操作的代码的安全检查)。

解决方案是重新设计我的应用程序,使 ESI 成为它自己的独立脚本标记。

So apparently the ESI tag wasn't getting processed because it was inside a //[CDATA[ block. I'm sure this has something to do with XML compliance. I thought that setting esi_syntax=7 would prevent such a problem, but it turns out that that only affects the content of the ESI itself (it doesn't lift the safety checks for the code which does the including).

The solution will be to rework my application so that the ESI is its own self-contained script tag.

維他命╮ 2024-10-15 20:08:33

尝试在“&”之前添加反斜杠在查询字符串中。

至少对我来说,如果你不这样做,Varnish 会忽略除第一个参数之外的所有参数。

例如:

也许您会遇到“[”和“]”的问题,并且它们还需要反斜杠。

Try adding a backslash before the "&" in the querystring.

At least with me Varnish ignores all parameters but the first one if you don't do it.

E.g.:

Maybe you'll have problems with the "[" and "]" and they will also need a backslash.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文