Today the Microsoft IIS team has released the beta of the Windows Cache Extension 1.0 for PHP.
The Windows Cache Extension for PHP is a PHP accelerator, that is used to increase the speed of PHP applications running on the Windows operating systems.
Any PHP application can take advantage of the functionality provided by the Windows Cache Extension for PHP without any code modifications. All that is required is that the extension is enabled and loaded by the PHP engine.
Install the Windows Cache Extension 1.0 for PHP – Beta
or, download:
Windows Cache Extension 1.0 for PHP 5.2 – Beta
Windows Cache Extension 1.0 for PHP 5.3 – Beta
Follow the instructions at “Using Windows Cache Extension for PHP” to install, enable and configure the extension.
Note:
- The extension can only be used with non-thread-safe builds of PHP
- The extension can only be used when IIS is configured to run PHP via FastCGI
- The Windows Cache Extension 1.0 for PHP 5.3 can only be used with the x86 VC9 build of PHP 5.3.
Benefits and Features
The extension includes three caches that can be enabled or disabled independently of each other:
- PHP opcode cache – PHP is a script processing engine, which reads an input stream of data that contains text and/or PHP instructions and produces another stream of data, most commonly in the HTML format. This means that on a web server the PHP engine reads, parses, compiles and executes a PHP script each time that it is requested by a Web client. The reading, parsing and compilation operations put additional load on the web server’s CPU and file system and thus affect the overall performance of a PHP web application. The PHP bytecode (opcode) cache is used to store the compiled script bytecode in shared memory so that it can be re-used by PHP engine for subsequent executions of the same script.
- File cache – Even with the PHP bytecode cache enabled, the PHP engine has to accesses the script files on a file system. When PHP scripts are stored on a remote UNC file share, the file operations introduce a significant performance overhead. The Windows Cache Extension for PHP includes a file cache that is used to store the content of the PHP script files in shared memory, which reduces the amount of file system operations performed by PHP engine.
- Relative file path cache – PHP scripts very often include or operate with files by using relative file paths. Every relative file path has to be converted to an absolute file path by the PHP engine. When a PHP application uses many PHP files and accesses them by relative paths, the operation of resolving relative paths to absolute paths may negatively impact the application’s performance. The Windows Cache Extension for PHP provides a Relative File Path cache, which is used to store the mappings between relative and absolute file paths, thereby reducing the number of relative path resolutions that the PHP engine has to perform.
More information
Use the Windows Cache Extension for PHP Forum to ask questions, report bugs and provide feature suggestions.






















Are there plans to support the thread-safe version as well?
Hi Joe,
Can you update the ASP.NET vs PHP performance tests so we can see how it will perform with the new cache extension?
Thanks,
Julian
To be accurate, caching extensions do not exactly increase the speed of execution of PHP code.
Caching extensions mainly store in a cache Zend opcodes that result from the implicit compilation phase that happens on every request right before the actual PHP code executes.
This means that in practice, it will not make the actual PHP code run faster. So, just loading this caching extension will hardly benefit the performance results of PHP on the ASP.NET benchmark.
What may make PHP code run faster, is using an opcode optimizer extension.
Other than that, what often makes PHP run faster is avoid using shared libraries for PHP or Web server extensions. At least under Linux, compiling and linking PHP and Apache as static libraries, makes PHP run 30% faster.
ilia.ws/…/32-Apache-1-vs-
That is one of the reasons why those ASP.NET vs. PHP benchmark results are not fair, as it seems PHP was not compiled on Linux to run in an optimized setup using only statically linked libraries.
@Manuel
"That is one of the reasons why those ASP.NET vs. PHP benchmark results are not fair, as it seems PHP was not compiled on Linux to run in an optimized setup using only statically linked libraries."
As Joe stated several times, the benchmarks show what you get directly out of the box. As such, they seem pretty valid to me.
Sorry for going off topic.
Regards,
Julian
Julian, there is no such thing as "PHP out of the box". PHP is distributed in many ways by different entities.
But if you want to consider that "PHP out of the box" is what is available in PHP.net, there is no compiled version of PHP for Linux, precisely because there are many different distributions and the binaries may be compiled in different ways that affect PHP performance.
In the real world, we compile PHP and Apache from source and link as static libraries to achieve maximum performance.
I understand that this may not be this way in the Windows world because it is all closed source, so you do not have the option to recompile binaries so they run optimally.
But if you want to be taken seriously and want to make fair comparisons, first learn how people work with platforms that you do not know but you want to include in your comparisons.
Joe, how do you want to be taken seriously while you keep making fun of those that make valid criticisms and point flaws of your evaluation methods?
If you do not want our feedback on how you can improve, so your tests can be taken seriously, just say so and we will not get back here to bother you.
Manuel – I welcome valueable feedback – I just get a kick that you seem to only come here to nay say.
I appreciate your passion but think your zeal shows your comments as unreasonably Anti Microsoft / anything not LAMP (as several responses to your comments indicate.)
Your comments are welcome – but I get to respond
Joe, you are certainly getting the wrong impression of me or maybe confusing with somebody else.
Do you think if I were anti-Microsoft I would ever attended the Microsoft Web Development Summit to which I was invited and attended in 2008? I have even given a talk there on how Microsoft can PHP run better on Windows.
http://www.slideshare.net/…/what-could-micr
I also went to Microsoft TechEd 2009 here in Brazil. Just FYI, I went to TechEd Ask the Experts session, took my notebook with Windows running Visual Studio with VS.PHP installed and showed to several people that asked how to develop PHP applications on Windows productively with Visual Studio and other Microsoft applications.
I am behind more initiatives of cooperation between Microsoft and PHP communities than you can imagine. I cannot comment on certain initiatives in public yet. Feel free to mail me privately if you would like to know more details.
So, definitely you may be taking me for someone else. If you still wonder, you may want to ask your colleagues Pierre-Alain Joye, Karri Dunn, Lauren Cooney, etc.
Anyway, the point that I am trying to make and it seems you did not yet get, is that if you cannot make fair comparisons that are based on real world conditions, it is better to not publish any resuls because it only promotes needless confrontation.
Confrontation between Microsoft and Open Source communities is bad particularly at this point precisely because some of us are trying to convince both sides that there are good chances of cooperation. Any incidents at this point will be counterproductive.
But if you insist that you need to publish the results of your tests, you need to adjust the conditions of your tests to reflect real production setups. That is all that I was suggesting to fix your tests.
Manuael – I know you were at the WDS
I put you on the invitation list
I’m not sure why you felt the need to post your resume here, I concede that you are a very importnant person !!!!!
I know pretty much all the conversations that take place at Microsoft relative to the PHP community …. I’m Glad that you are finding benefit to working with Microsoft (as I’m sure you aren’t doing things for charatable reasons only.)
YOu and I simply have differeing opinions – you feel that I am not objective – I feel that you are not. The ability to disagree respectflly is a great learning experience.
My opnion of your "beating the horse" comments is just that, my opnion. I conceed that you are entitled to your opinion even though I disagree with you.
Perhaps you could afford me the same curtosy (here on MY blog) without needing to qualify your comments with offhanded addendums.
I have the pleasure and luxury of writing BOTH .NET code and PHP code as part of my job. Many people find my perspective on the comparison that comes from that work usefull.
I understand that you do not – but it is YOU that keep coming here to tell me that my comparisons are not fair and that I sould post test results. Perhaps your relative exclusivity of being a PHP Developer and running a huge PHP site restricts the diversity of your perspective just a bit.
With all due respect Manuel – YOU are NOT "the PHP Community" you are one dude ! I post for folks that find my learings usefull. Some folks find it just that, other’s don’t. Such is blogging.
Since this is my blog, I get to post anything (legal) that I like, just like you do on your site.
I don’t come to your site (every day) to impune your contentions or say that you are not being fair (in truth I think your perspective is so bais that you can not be fair yourself.)
You have posted that you think my PHP tests are unfair, meanlingless, innacurate. THIS POST HAD NOTHING TO DO WITH THAT but you are stuck on those test results.
I’ve posted my tests, your posted your opinions, how about if he let people read both and decide if they are usefull to THEM.
When I post the next set of PHP/ASP.NET stuff I promise to give you a bunch of new stuff to be worked up about:)
Joe, please "put that gun down".
You are still not getting me right. Let me explain once more.
I did not come here to claim I am an important person. I just mentioned facts about my recent activity that demonstrate that I am not anti-Microsoft unlike you claimed.
I did not comment on this thread to beat any horse. If you go and read thread again, you may notice that it was actually Julian that brought here the topic of the ASP.NET versus PHP benchmark. So it was not me that is making that topic recurring on your blog comments.
I just explained to him that opcode caching extensions will not make PHP code execute faster, and explained what makes PHP run faster is using opcode optimizers and compiling PHP (runtime) and linking it to Apache as static libraries, otherwise the benchmark comparisons will never be fair.
Maybe you are aware of that already. It seems that Julian didn’t, my comment was directed to him.
So, as you may realize I just commented on prior comment in order to let people understand what matters and what doesn’t. I think it is useful when people bother to comment to clarify misunderstandings, even when it brings back past issues.
I hope it is clear for you now that by no means I am not after you on this. So there is need to act defensive as if I would have intention to upset you anyhow in your blog.
@Manuel:
"But if you want to be taken seriously and want to make fair comparisons, first learn how people work with platforms that you do not know but you want to include in your comparisons."
This is bit lame. I my "real world" I’m buying a hosting account. It comes with PHP and mySql pre-installed and PHP.ini pre-configured. In my home, i’m downloading the stuff from PHP.net and than configuring IIS7 to work with it. In my work it is exactly the same – our clients are using exactly the same "out of the box" configuration on their servers. Lots of clients, all of them
Seems my "real world" is not your "real world". Fair enough
Joe, I thought that you did not want to carry on discussing the benchmark issues because they were unrelated with actual post.
Anyway, if you insist, I will explain to you where I see flaws in your argumentation. Keep in mind that I am not fighting you. I am just trying to help you see where you are making judgment mistakes that compromise the credibility that people see in your tests.
Above, you just demonstrated why your comparisons are not fair. Why do you think it is fair to buy a hosting account that comes with PHP and MySQL pre-installed, and then compare with ASP.NET running on your own home machine that is dedicated?
Why didn’t you run PHP on Linux in the same dedicated home machine like you did for Windows tests? I can understand that you may not have a spare machine to do it, but if you want to make fair comparisons, consider installing Linux on the same machine with dual boot, so nobody has excuse to complain about the conditions of the tests that were not equal.
Also, since it seems you are not a regular Linux user, you may not perceive that the daily practices are different from those of the Windows world. Let me explain.
Unlike with Microsoft products, Linux, MySQL and PHP are Open Source. Therefore, we are free to recompile them with options optimized for the current machine CPU and architecture. This is a common practice in the Linux world.
In the real world of hosted Web sites, when you need performance, you buy or hire a dedicated server, not shared hosting accounts. If you buy a shared hosting account, you are certainly not concerned with performance.
So, if you want to include Linux in your tests, to be fair you need to follow the common practices that we all follow when we install PHP. We ditch any pre-built PHP from the Linux distribution and just recompile PHP from source.
PHP for Windows is the same source code. You can recompile PHP for Windows with optimized options for your machine. Then you can make fair comparisons.
@Joe and @Manuel,
C’mn guys, quit it already. I find Joe’s posts usefull as they are helping me in making some decisions for my next project. Manuel is not anti-Microsoft, otherwise he wouldn’t be buzzing around this blog.
@Joe, the windows php caching seems cool; finally one easy, out-of-the-box caching system. I hope php group comes up with something similar for linux. APC is mystical, the results are contradictory (at least for someone at my expertise level).
I’ll just use absolute paths for includes and put everything in a function and/or class. Those techniques seem to have better (way better) results than using APC. For output cache, CacheLite is enough.
Luis, you are quite right. I am not anti-Microsoft, quite on contrary, I fully support initiatives of Microsoft to make PHP run better on Windows.
I also think Windows Azure is great because it addresses an important problem of the scalability of Web sites, and Microsoft greatest competitors on that field are either seriously lagging (Amazon) or simply uninterested in PHP (Google).
This caching extension is also a good addition to make PHP solutions run better on Windows servers, on the cloud or not.
I also hope competition catches up because Azure hosting prices are still too expensive to be interesting.
Anyway, just to clarify one point, PHP caching extensions exist for Linux, Windows, etc,, since 2001. APC is just one of several. It is just not shipped with the regular PHP distribution because Zend guys always opposed to include it, at least until PHP 6, but that was not due to any technological issue.
RE: Introducing The Windows Cache Extension for PHP
Web Storage Systems for High Scalable Systems Presentation The Anatomy of Hadoop I/O Pipeline Build an