NAME

Plack::Middleware::ESI - PSGI middleware for Edge Side Includes (ESI)

VERSION

version 0.1

SYNOPSIS

use Plack::Builder;

my $app = sub {
    return [
      200,
      [ 'Content-Type' => 'text/plain' ],
      [
        "The Google front page as plaintext: ",
        '<esi:include src="http://google.com/" />',
        "And a local request might be nice: ",
        '<esi:include src="/userinfo/" />',
      ]
    ];
};

builder {
    enable "ESI";
    $app;
};

DESCRIPTION

This module provides rudimentary support for using Edge Side Includes in PSGI applications.

The primary aim is to support the same subset of features as the Varnish caching proxy server. Essentially, this means support for three ESI tags:

  • <esi:include src="..." /> - Include the contents of a remote or a local URL. Please note that the alt and onerror attributes are not supported.

  • <esi:remove>...</esi:remove> - Remove a section of the document.

  • <!--esi ...--> - Unhide whataver is inside the HTML/XML comment (which is normally the result of applying an ESI include tag).

The module only filters responses with a Content-Type of text/*, application/xml, or application/xhtml+xml. This obviously means that the Content-Type output header must have been set further down in the middleware stack (or, of course, in the original PSGI app itself), before the ESI middleware is applied.

AUTHOR

Baldur Kristinsson <bk@mbl.is>

SEE ALSO