Over the past few years, Microsoft has done a lot of work to optimize the performance of PHP on Windows server so that everyone benefits.
For instance, the folks behind PHP now have the support of one of the biggest application platforms in the world, the programmers who write in PHP enjoy enhanced performance for their applications on Windows servers, users of said applications wait far less for pages to serve up, and Microsoft sports another feather in its Windows server cap.
One of the ways PHP can be further accelerated in Windows servers is through Windows Cache Extension for PHP, an add-on for PHP under Internet Information Services (IIS). It's a free, open source tool that's BSD-licensed, so its code
can be ported, reused and redistributed with extremely minimal restrictions. The source code is hosted directly at PHP.net along with full documentation.
The current version of Windows Cache Extension for PHP is 1.01, and a 1.1 beta is available for public download and evaluation. Note, however, that it's not recommended to use the beta in a production environment.
Windows Cache Extension works by caching in the bytecode (the compiled version of PHP scripts), similar to Microsoft's Active Server Page (ASP) caching and acceleration process. Most sites that use PHP tend to run the same scripts, so caching them automatically grants a greater performance boost.
The tool also caches a number of other things, including:
- files used by PHP scripts (both the scripts themselves and the files called by those scripts)
- absolute file paths as resolved from relative paths
- memory occupied by objects and variables, which can be shared between user sessions
- session handler data
Note: The last two are only available in the current 1.1. beta version.
Before installing Windows Cache Extension for PHP, make sure you have the correct system requirements -- typicallythe most recent IIS Web server release with PHP versions 5.2.0 or better -- and the FastCGI extension.
The installation process requires a little manual monkeying-about (nothing too outlandish, thankfully). For instance, the program's runtime settings can be manually edited through a .ini file. Among the things that can be changed are the sizes of the various caches and which files (if any) are not to be cached for whatever reason. Note that some of the cache sizes are dependent on each other, so it's important to read the documentation for the settings to determine how one may affect the other.
Right now only x86 versions of the cache extension are available; there's no x64 edition, but the 32-bit version should work as-is in 64-bit Windows servers. It's also recommended that you use the VC9 non-threadsafe version of PHP (which is what's generally recommended for Internet Information Services anyway).
Finally, if you're curious about profiling the application's caching performance, the installation package includes a script that lets you dump out a rundown of Windows Cache Extension for PHP's caching statistics.
ABOUT THE AUTHOR
Serdar Yegulalp has been writing about computers and information technology for more than 15 years for a variety of publications, including InformationWeek and Windows Magazine.