ESI (supported by Varnish and Akamai and with a slightly different syntax by nginx) allows for HTML tag-like commands in the page source like <esi:include src="http://example.com/ssi.php?key=abcd" > so that the static parts of the page is cached in (for example) Varnish and only the dynamic bits are fetched dynamically. ssi.php is a very small program that connects to, say, memcached reads the value of the specified key and prints it (this esi.php is completely David Strauss' idea). Now, if Drupal would be able to serve page templates and cache the dynamic pieces into memcached then we could scale through the roof. And we are close... patch to follow I just wanted to file the issue so I can link to it from the code comment.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

chx’s picture

FileSize
1.02 KB

Note that there are no cache implementations that return strings on cache_set so this is a completely harmless addition to core. The speed penalty is extremely minimal: one if and that's a simple if (and cache_set is a relatively rare operation). Once this is in we can add a few lines to say memcache.inc to return the ESI command when adequate (like using a cache_esi bin). (Yes, memcache is ported to D7, with tests)

Dries’s picture

Interesting, but the code comments are lacking.

catch’s picture

Issue tags: +Performance

joshk has been working on something similar to this with Panels in D6 apparently, not sure where the patch lives though. In other words subscribing.

Damien Tournoud’s picture

FileSize
1.64 KB

I think this is actually enough to support ESI properly. It's still a little bit hackish (the only true, non hackish, solution would be to make drupal_render_cache_(get|set)() pluggeable... but that would be a significant API change), but it looks nicer I believe.

chx’s picture

I like Damien's version. It really is simple.

mike booth’s picture

Subscribing.

moshe weitzman’s picture

Status: Needs review » Reviewed & tested by the community

I like it too. Good to go, IMO

pwolanin’s picture

the change to function drupal_render() looks like a minor optimization unrelated to ESI support?

Dries’s picture

+++ includes/common.inc
@@ -5203,13 +5204,15 @@ function drupal_render_cache_get($elements) {
+  // Cache implementations are allowed to modify the markup, to support
+  // edge-side replacement of the cached markup.
+  $data['#markup'] = &$markup;

Looks ready to me, but I'd like to see this code comment to be expanded a bit more. Let's add one or two more sentences to be a bit more concrete.

webchick’s picture

Status: Reviewed & tested by the community » Needs work
chx’s picture

Title: Allows ESI tie in » Allow ESI tie in
Status: Needs work » Needs review
FileSize
1.73 KB

Written a long comment. @pwolanin no, we now can cache #prefix and #suffix too.

sun’s picture

Status: Needs review » Reviewed & tested by the community
scor’s picture

FileSize
1.72 KB

removes a whitespace from #11.

Dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to CVS HEAD. Thanks!

Status: Fixed » Closed (fixed)

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

Wim Leers’s picture

Awesome! :)

brianmercer’s picture

subscribed

ecctao’s picture

After this the tage donot work, How?