I encountered an interesting problem, without any clear solution in front of me. To save you from a lot of reading, I just deleted a 3 paragraph rant about the software I'm replacing.
Now, what I have is a 3 part system. First is the Catalyst application that runs in a secure environment and handles purchases and registrations. The second larger component is the content management, which is comprised of the legacy system and the new Movable Type based system.
MovableType was a fantastic choice, for the static publishing and easy user interface. While the asset management could be better, I can always fix that for our needs after the fact (which I will be, most likely).
The problem is getting 3 applications to live together harmonously when they're very disjointed. I don't really want to server the MovableType CGIs, so I can block any .cgi scripts at the frontend.
MovableType would be able to handle everything together, except for one caveat: A user logged in, with a valid membership, is presented with different content.
This, quite obviously, is a fantastic case for ESI. I think most people in the MovableType world would have their templates omit PHP and put the generated HTML files behind Apache and PHP.
Hell no.
There's 3 reasons for this:
- I hate PHP
- I don't want the bloat of dynamic pages when it isn't necessary
- I already have an application that has all the snippets of templates, and uses a unified CSS structure
So, the only thing I'm missing is a controller that renders the atomic units of the logged in snippets.
This primarily consists of a few member benefit pages (showing redemption instructions) and menus, as is the typical case with ESI.
Now, this doesn't make sense in just words. So here's a picture that also doesn't make sense:

In a nutshell, all that is really happening is a server-side include. It's similar to PHP, except you have a proxy-based load balanced backend cluster that can be accessed via an internal network (or on the same server, if you're a single-server setup). The ESI processing can be very simple to setup, and all your application needs to do is spit out the little snippet of a page.
The downside of this is your application processes one request for every ESI include, which can honestly get a bit costly but there are some better perks here over letting a browser do it. First, Varnish can use a keep-alive socket and stream the requests better, as well as providing caching on the individual ESI components and store the individual components inside of its main cache.
Continue reading Varnish and MovableType for content management and application integration.