ESI tag processor for the connect framework
The purpose of connect-esi is to provide simple Edge Side Includes (ESI) processing via a post request filter on top of the connect framework.
It works as follows:
- response.write behaviour is modified to search for esi:include tags
- if tags are found, each src attribute from the esi tag is fetched via http.get
- on http.get response, the original esi tag will be substituted with the content from the response
- when all esi tags have been substituted, the final page is displayed
This package is in its early stages and still needs some work. As with any of our projects, constructive criticism is encouraged.
npm install connect-esi
Note that connect-esi was developed using CoffeeScript.
To utilize connect-esi, simply require it and then have the connect server use the setupESI() method. To make sure that no other modules conflict with connect-esi, it should be used by the connect server before other 'use' methods.
connectESI = require 'connect-esi' server.use connectESI.setupESI()
Client Side Includes (csi)
esi-parser.js will loop through all esi and csi tags on a page and request relevant sources. This script depends on jQuery and PMScriptManger.js. It is currently coded to work with our timbits project (see https://github.com/Postmedia/timbits) in that it will append &esi_id=esi_id&remote=true to the esi/csi src and will expect a script to return. Look at the server source to see how the script response should be formatted (the contents of the response should be inserted into jQuery("#esi_id")).
- none at this time
- Stephen Veerman