Enabling WINCACHE on per site basis

With WINCACHE 1.0 RC one can configure parts of WINCACHE solution on a per site basis. As you know WINCACHE has two kinds of cache namely output code cache and file cache. With RC release, you have the ability to turn output code cache on a per site basis. We have got a new WINCACHE directive named WINCACHE.OCENABLEDFILTER which can be used to enable/disable output code cache on a per site basis. This INI directive can take a string which is list of comma separated  numbers. Each number in the string represents a valid site id which is a unique identity IIS gives to each Web Site when the site gets created. All the site id included as part of this string will actually toggle the value of WINCACHE.ocenabled while running WINCACHE functionality. Example, if you have below in your PHP INI file:



This means for site having id 2 or 3, WINCACHE output code cache will be disabled and for all other site id, it will be enabled. So this is an extremely easy way of turning WINCACHE output code cache on a per site basis. Some users also gave us suggestion that we should have a similar switch for WINCACHE file cache. Yes, we have heard you and a similar INI directive named WINCACHE.FCENABLEDFILTER has been added for the final RTW release of WINCACHE 1.0. This feature will make the enabling/disabling cache feature on a per site basis complete.

Let's talk about how we have implemented this. IIS sets a server variable named INSTANCE_ID which is set to site ID for that Web Site. We check for that in the WINCACHE code using Zend function and toggle the feature appropriately. This is a good feature because this is independent of PHP and can work with both PHP 5.2 as well as PHP 5.3.

By the way, PHP 5.3 also gives you a way to achieve the same thing using PHP_INI_PERDIR concept. Let's say you have two site SITE1 and SITE2 and their respective physical path point to (equivalent to server variable 'DOCUMENT_ROOT') C:\inetpub\wwwroot1 and C:\inetpub\wwwroot2. Here is how you can enable WINCACHE for SITE1 and disable the same for SITE2. In your PHP.INI file include this:







The above will do the trick. One thing to note here is that PHP_INI_PERDIR doesn't work properly for PHP 5.3 on XP and Windows 2k3. All the bugs related to this has been fixed and you can get it work using the latest snapshot from here.

Hope this is going to help you. Thanks for the patient reading and good bye.



  • Thanks for the WINCACHE.FCENABLEDFILTER option ! It's will be useful for me.

    I suppose, we can also use the PHP_INI_PERDIR method to set other wincache directives per site like wincache.chkinterval ?

    I will test the latest PHP 5.3.1 snaps because effectively, I can't use PHP_INI_PERDIR with PHP 5.3.0 and IIS 5.1...


  • Yes PHP_INI_PERDIR can be used to set other WINCACHE directives too.

    PHP_INI_PERDIR is broken in PHP5.3.0 for XP/2k3. PLease use the 5.3.1 snapshot. That should have the fix. I tested it and it works fine for me.


Comments have been disabled for this content.