• About

NYT xslcache

October 26th, 2007

The New York Times has released a modified xsl module for php5 which caches xsl transformations. I just built it on ubuntu and debian:

apt-get install php5-dev libxslt1-dev
tar -xzvf xslcache.tar.gz
phpize./configure --with-xslcache=/usr/lib/ --with-xsl-exsl-dir=/usr/lib/
cp modules/ /usr/lib/php5/20060613+lfs/
cp /etc/php5/conf.d/xsl.ini /etc/php5/conf.d/xslcache.ini
vim /etc/php5/conf.d/xslcache.ini

Cool. I got it to work with nexista, albeit a little funkified. It seems it can't accept a DOM Document like the regular XSLT processor class can, I had to save the xsl template after it had been loaded and entities transformed, and then have the XSLT object load in the file. Strange, but it worked, and I actually think this might be the right way to go - cache the xsl file with its entities converted and be done with it.

This extension is actually very nice. I agree with some of their assumptions - that the XML data in an XSL transformation is likely to change, not the stylesheet. And the cache is set to expire when the modification time of the source file is changed. Very good. As I mentioned earlier, I have to use a DOM Document to convert some entities prior to the xsl transform, so I'm saving a temp file before loading it with the XSLTCache object. This requires another cache check of course.

If you've been reading Docunext for awhile, I'll all about the caching. I try to cache database queries, php optcode, rendered pages, gzipped content, and even employ client caches. Why? Its by far the best performance boost available!

My results? Nexista is showing up to a 25% performance increase, or in other words, a page taking 0.2 second to load only takes 0.15 seconds to load after the XSL document has been cached.

Debian package of php5-xsltcache


Control file:

Package: php5-xsltcache
Version: 5.2.3
Section: web
Priority: optional
Architecture: i386
Depends: php5-common (>=5.2), php5-xsl
Maintainer: Albert Lash
Description: PHP 5 XSLTCache Similar to php5-xslt, php5-xsltcache caches xsl documents in  permanent memory, but keeps an eye on modification time of  referenced file. See:

UPDATE November 1, 2007: Apache can do this stuff too! See my post on mod_transform!

Yearly Indexes: 2010 2003 2005 2006 2007 2008 2009 2004 2011 2012 2013 2015 2019 2020