From Wikipedia, “ESI or Edge Side Include is a tiny markup language for edge level dynamic web content assembly. The purpose of ESI is to tackle the problem of web infrastructure scaling.” It is incredibly useful and can help to provide services for your web sites or web applications.
You can find the ESI plugin for Apache Traffic Server here. When I tried to compile it and make it work with traffic server 3.0.4, I got some errors. Even when I manage to compile it, the runtime is not actually working, too.
So i decided to try to fix it. Here are the list of problems I find and fix.
- Some “if” statements are checking whether the TS functions are returning 0 or not but actually we should check against TS_SUCCESS or TS_ERROR
- TSFetchUrl is still requiring ip and port as parameters so we need to pass them in
- VConnWrite() should use INT64_MAX instead of INT_MAX. This is causing the ESI template with ESI include to return with a 2^32 -1 content length and causing the client to hang till timeout.
- There is a mechanism to cache a parsed version of ESI template through a POST request internally but I find it hard to get it working. I can’t get my ESI template with a valid cache control header to get properly cached in ats (which is somewhat useful to what i do). So I try to disable that.
The working code can be found here. My fixes for #4 is quite hacky and there are actually lots of things we don’t need if we don’t do the internal POST request. So there will be more cleanup needed.
The plugin seems to work well. I tested with ESI try/attempt/except syntax in my ESI response. I tested with multiple ESI includes. I tested with cache control header added for the ESI response so that I get the ESI Response cached in ats and subsequent requests will simply get the ESI response from cache instead of OS server. Gzip is also working, too.
Next time, I will talk about a few use cases that makes ESI incredibly useful for web sites and web applications.



