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 ?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

bellesmanieres’s picture

Patch only fixes the issue for the panels submodule, pending feedback on a more global approach.

frankkessler’s picture

Status: Active » Needs review
FileSize
1.47 KB

This 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.

frankkessler’s picture

Title: ESI does not restore original request url on exit » ESI does not restore original request url on exit so page cache only stores esi fragment for each page

  • dstuart committed 7439713 on 7.x-3.x authored by frankkessler
    Issue #2231565 by frankkessler: ESI does not restore original request...
dstuart’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.