The ESI panels and blocks module, do override $_GET['q'] and $_SERVER['REQUEST_URI'] with the original values of the page it was included. That's needed for proper content generation, for sure. Problem is that on delivery, esi_deliver_esi_component calls drupal_page_footer. Depending on your various cache settings both drupal and varnish sides, this will lead drupal to cache the content of the ESI under the full page path. Result obviously is that a visitor hitting a page with an ESI include that has been cached that way will be served the ESI content itself instead of the page.
Resetting the original context in hook_exit does prevent that from happen (patch provided for the panels submodule), but it should probably be handled globally by the main esi module. This would mean adding the original url to the esi url from the esi module itself instead of having that done for each submodules. Page callback esi_handle_component would then retrieve it at the page callback, and reset the original values before passing back the renderable array to the the delivery callback. Does that make sense ?
Comment | File | Size | Author |
---|---|---|---|
#2 | esi-reset_request_uri_at_exit-2231565-2-D7.patch | 1.47 KB | frankkessler |
#1 | reset_request_uri_at_exit-2231565.patch | 1.04 KB | bellesmanieres |
Comments
Comment #1
bellesmanieres CreditAttribution: bellesmanieres commentedPatch only fixes the issue for the panels submodule, pending feedback on a more global approach.
Comment #2
frankkessler CreditAttribution: frankkessler commentedThis is a pretty nasty bug. I couldn't find this issue so I'm going to add a little extra text in case others searching find it.
Without changing the URL back, the page cache will store just a snippet on the homepage for the entire homepage URL. If you are load balanced and serving from multiple servers, the second server to hit the page cache will only show the snippet and not the entire page. If your page is loading only the ESI snippet and it seems to only happen sometimes, you are hitting this bug. See the attached patch to fix it.
Comment #3
frankkessler CreditAttribution: frankkessler commentedComment #5
dstuart CreditAttribution: dstuart commented