Caching and dynamic content

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Caching and dynamic content

Post 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.
mrkite
Forum Contributor
Posts: 104
Joined: Tue Sep 11, 2007 4:19 am

Re: Caching and dynamic content

Post 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).
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post 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?
mrkite
Forum Contributor
Posts: 104
Joined: Tue Sep 11, 2007 4:19 am

Post 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.
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

Savvy. But what about those of us who don't have the ability to load custom Apache modules?
mrkite
Forum Contributor
Posts: 104
Joined: Tue Sep 11, 2007 4:19 am

Post 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() :)
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post 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.
Post Reply