I am tasked with improving page serving time for a rather big deployment of wordpress multisite.
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.
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)
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? 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.
精彩评论