简体   繁体   English

清漆ESI多个片段,单个请求?

[英]Varnish ESI multiple fragments, single request?

I am tasked with improving page serving time for a rather big deployment of wordpress multisite. 我的任务是为相当大的wordpress多站点部署提高页面服务时间。

I am considering using varnish for full page caching of content and using it's ESI abilities to include the dynamic content associated with the logged-in state of a user, also handling cache invalidation in the application by using varnish purge list that matche a custom header of the blog's id or some other custom headers containing article ids and/or user ids. 我正在考虑将清漆用于内容的全页缓存,并考虑使用其ESI功能包括与用户登录状态关联的动态内容,还通过使用与自定义标头匹配的清漆清除列表来处理应用程序中的缓存失效。博客的ID或包含文章ID和/或用户ID的其他一些自定义标题。

I'd like to know if anyone ever figured a way of including multiple page fragments through ESI while grouping them in a single response from the backend (eg. we must display the user's name in the menu and a custom user widget in the sidebar, the rest of the page is static and cached by varnish. ESI mandates that I make two requests to the backend in order to retrieve the two fragments and place them at their proper location while at the backend i could easily generate the HTML code for both in a single run and return it to varnish for processing) 我想知道是否有人想出了一种通过ESI包含多个页面片段的方法,同时将它们分组到后端的单个响应中(例如,我们必须在菜单中显示用户名,并在边栏中显示自定义用户小部件,该页面的其余部分是静态的,并由varnish缓存。ESI要求我向后端发出两个请求,以便检索两个片段并将它们放置在适当的位置,而在后端,我可以轻松地为两个片段生成HTML代码一次运行并将其返回清漆进行处理)

What about having the ESI return the HTML chunks in one request and wrapped in some Javascript logic that fires to place the various HTML strings in the appropriate places? 如何让ESI在一个请求中返回HTML块并将其包装在一些Javascript逻辑中,然后触发该Javascript逻辑以将各种HTML字符串放置在适当的位置? A little odd, but solves your problem, and shouldn't be very difficult to implement. 有点奇怪,但是可以解决您的问题,并且应该很容易实现。

Another option with fewer moving parts would be to group all the HTML chunks you'd be getting via the ESI include at a single point in the page, say the bottom, and then use CSS to absolutely position them where you want on the page. 移动部分更少的另一种选择是将您将通过ESI获得的所有HTML块分组在页面的单个位置(例如底部),然后使用CSS将它们绝对定位在页面上所需的位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM