connect-esi

0.2.4 • Public • Published

connect-esi

ESI tag processor for the connect framework

Introduction

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:

  1. response.write behaviour is modified to search for esi:include tags
  2. if tags are found, each src attribute from the esi tag is fetched via http.get
  3. on http.get response, the original esi tag will be substituted with the content from the response
  4. 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.

Installing

Just grab node.js and npm and you're set:

npm install connect-esi

Note that connect-esi was developed using CoffeeScript.

Using

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")).

Outstanding Issues

  • none at this time

Created by

  • Stephen Veerman

Readme

Keywords

none

Package Sidebar

Install

npm i connect-esi

Weekly Downloads

1

Version

0.2.4

License

none

Last publish

Collaborators

  • veerman
  • mred9