Page 1 of 1

Caching and dynamic content

Posted: Wed Sep 12, 2007 6:47 pm
by Ambush Commander
Attempts to cache data have always been in conflict with the desire to have as dynamic pages as possible. In my current knowledge, the current modus operandi of systems that want to cache and be dynamic at the same time pre-generate as much of the page code as possible, and then perform a few simple string substitutions afterwards.

I'd like to propose this one more step further: generate and cache the static page, and serve the dynamic content via JavaScript/AJAX! Is this feasible? Accessible? I suppose for essential dynamic data this wouldn't work well, as well as interactive pages.

My ulterior motive is that I'm trying to figure out performance-friendly ways of using XSLT in high-traffic contexts. It's such a great language, pity that it consumes so many resources.

Re: Caching and dynamic content

Posted: Wed Sep 12, 2007 7:08 pm
by mrkite
Ambush Commander wrote: My ulterior motive is that I'm trying to figure out performance-friendly ways of using XSLT in high-traffic contexts. It's such a great language, pity that it consumes so many resources.
XSLT is extremely fast, if you use the right parser.

We have libxslt and libxml2 compiled into a custom apache module. This guy handles 10 million transforms per month off a single Sun Ultra 60 (450mhz).

Posted: Wed Sep 12, 2007 7:10 pm
by Ambush Commander
Mmm... that's about four transforms a second. Not too shabby. Though, are you invoking it with PHP as a separate process (which probably would be quite slow) or is Apache handling the transforms itself?

Posted: Wed Sep 12, 2007 7:27 pm
by mrkite
Ambush Commander wrote:Mmm... that's about four transforms a second. Not too shabby. Though, are you invoking it with PHP as a separate process (which probably would be quite slow) or is Apache handling the transforms itself?
The apache module is written entirely in C++ and does the transforms internally. PHP on a different server talks to the apache module through SOAP requests.

The XSLTs are sitting on disk and the XMLs are either built on-the-fly by the apache module, or pulled from mysql (by the apache module) depending on the SOAP request.

Posted: Wed Sep 12, 2007 7:30 pm
by Ambush Commander
Savvy. But what about those of us who don't have the ability to load custom Apache modules?

Posted: Wed Sep 12, 2007 8:21 pm
by mrkite
Ambush Commander wrote:Savvy. But what about those of us who don't have the ability to load custom Apache modules?
You can do some speed tests on running xsltproc through exec() :)

Posted: Wed Sep 12, 2007 8:24 pm
by Ambush Commander
In theory, the PHP extension should have comparable results: it is based off of libxml2 and libxslt, after all.

But still, caching in general is a good idea, because it means things like Squid Proxies can do magical things.