|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #58993 In a web garden wincache_refresh_if_changed not behaving correctly
Submitted: 2009-12-14 23:15 UTC Modified: 2010-02-20 13:17 UTC
From: Assigned: DonRaman (profile)
Status: Closed Package: WinCache (PECL)
PHP Version: 5.2.11 OS: Windows
Private report: No CVE-ID: None
 [2009-12-14 23:15 UTC]
Here is what Julien (our customer) has to say:

Hi Don,

I am facing to an other problem related to the use of WinCache with multiple worker processes for one application pool (web garden).

When I use the API wincache_refresh_if_changed() to refresh my cached files, I have to execute the function many times successively for the modification being really applied. In effect, if I execute only one time this function, only the cache of one worker process is refreshed. The second cache for the second worker processes is not refreshed and I have to click on my button many many times... It causes random behavior of my website. Some clients obtains the old PHP code and some other obtains the new PHP code.

Do you think it's will be possible in the future to refresh the cache for the whole IIS website when we use the wincache_refresh_if_changed() API ? I think the difficulty is that the same application pool (worker process) can represents multiple different websites and it's would be like a security issue if the API refresh all the application pool...

I have an other exemple of a problem I have with the memory management of WinCache. I have a website named and a forum named . The administration pages of the website and of the forum are both located at the URL . And it is also in this administration interface where I have added a button to execute the wincache_refresh_if_changed() function. When I run this button, only the code of the is refreshed and not the code of the forum.

The website and the forum use two different application pools (additionnaly each of them with two worker processes :) ).

I don't know if there can be a solution to this problem... Perhaps with WinCache 2.0 ?


Reproduce code:
The repro is very trivial. One just need to have a web garden meaning multiple worken process configured for same web site.

Expected result:
There should be a way to refresh a file in a web garden.

Actual result:
There is no way to achieve this in a deterministic way as of today.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-12-14 23:16 UTC] don dot raman at microsoft dot com
The problem here is that the API wincache_refresh_if_changed() has to be executed by at least one php-cgi.exe running in all different worker process. This is highly non-deterministic from a user's standpoint because user cannot control which request goes to which php-cgi.exe.
 [2009-12-14 23:17 UTC] don dot raman at microsoft dot com
Assigning to myself for final resolution. Might get re-assigned later.
 [2009-12-14 23:30 UTC] don dot raman at microsoft dot com
A workaround is to use wincache.ignorelist directive in this case. Since this is a PHP INI directive this will be picked by all the instance of worker process running WINCACHE.

A slight disadvantage is that this directive takes just the file name, so if you have two sites Site1 and Site2 in IIS having file named admin.php and if you have set
This will solve the above problem but will ignore caching of admin.php in Site2 also.

I see this as a good enough solution. Please let us know if this is not acceptable and why.

The other solution I can think of is to introduce a new WINCACHE directive named refreshIfChanged and support full/aboslute path in here. We can do the same enhancement to ignoreList directive but that will ignore the file completely from caching.

If the above workaround is acceptable I would rather not do this enhancement.
 [2009-12-16 18:17 UTC] julientld at free dot fr

Setting the directive wincache.ignorelist with my namefiles is not very helpful. I do not know in advance which files will be modified and have to be refreshed by the two worker processes. And I want theses files to be present in the cache! Perhaps I do not understand something in your explanation ?

In fact, I have two different problems with memory and WinCache :

* The main problem (no doubt it is a bug) is that the wincache_refresh_if_changed() function refresh the cache only for the worker process in which it is executed. I think you have to find a solution to send a refresh "signal" to all the worker processes used by the current Application Pool (with a restriction to the current website ? see below). Don't know if a such "signal" is possible...

* My second problem concerns also memory management but is a little different. In fact I don't know if it is actually a real problem or a normal behavior of WinCache. As I said you I have two websites executed in two different Applications pools (#1 = main website, #2 = forum). I wish to being able to refresh the cache of the website #2 when executing the wincache_refresh_if_changed() function from the website #1. It does not work actually and it is normal I think because there are two different application pools. Also, it's would be wrong if there are multiple customers/webmasters on the same server and if all of them can refresh the cache of others...

I do not know if you want to enable this possibility but a solution could be to add a parameter to the function wincache_refresh_if_changed(). This parameter could be a list of IIS websites ID for which we want to refresh the cache. Per exemple: wincache_refresh_if_changed(null,"1554540,1878730") will refresh the cache for all files of the the websites 1554540 and 1878730. There would be no "security" issue I think because IIS websites ID are only visibles for the administrator of the server or for the current website webmaster. So no chance for a user to refresh the cache of an other user.

I think that in all cases you should have to implement in addition to the notion of application pool, a concept of website ID in the refresh cache mechanism.

Hope, my "ideas" will help...

 [2009-12-16 22:40 UTC] don dot raman at microsoft dot com
wincache_refresh_if_changed() function was provided for the very same reason. If one doesn't know which file will change this function can be used to refresh the file instantly and dynamically. 

Also remember that your edits will eventually take effect depending on wincache.chkinterval directive, so the stale file is not going to stay forever in the cache. Also if the file in cache is not used, it will also get scavanged.

So my point is eventually the file will get picked up. However your problem is bit unique because of web garden infrastructure. Remember this will never happen in scenario where a site is configured to run one worker process and this is most usual scenario I have seen.

Your idea of signal is also not an option. First thing sending such signal is not easy and even if I can send signal to other worker process, the php-cgi.exe in that worker process has to run to impact the change. For a similar reason passing extra paramter is not a solution. See we can change the function wincache_refresh_if_changed() or send signal but eventually php-cgi.exe in that worker process needs to execute it.

I have few question for you:
1. How often you change the file?
2. If it is not very often, can you just recycle the application pool?

I want to fix every bug, but this seems like effort involved in fixing this is not worth the scenario. Please let me know if this is unacceptable. In the meantime I will also ask my developer and see if he can think of something simple.

And thanks for all the help in making WINCACHE a better caching solution on WINDOWS.
 [2010-01-25 00:55 UTC] sam951_1969 at hotmail dot com
i have a hp 540 je cherche ds la monteregie et ou montreal des endroit peux dispendieux car je n est que peut  d argent.  ds ma recherche  j ai trouver sur DELL (je ne crois je dessire avoir avec mon new ordinateur. pas qu il un investissement a cout le plus bas.

je recherche : ecori7 avec 3TB,hdmi2 fois,3TB de 3d et 3TB audio.2 fois 3TB pour ram. 3TB fois 5 disque dures. audio avec bon speaker,ecrant 23 pouce,cameraa integrer.Et tout ce qui doit etre ds un ordinateurs et je veux windows 7, corriger les fautes orthographe,anti-verus qui fontionne pour bouclier de l ordinateurs et du sit veusque mes connections sois faite ave des fils en plastique de couleurs regarder HP , INTEL"et fete une recherche si vous porvez-vs de voire sit ils aurais etre ds la competitions est voir ci ils veulent  desscendre leurs prix. car j ai fait des estimmer chez DELL et meme si je prends le  moin chere des ordinateurs je n aurrais jamais ce que je vous est demander ci-haut. mrci d avance de fire une demarge comme moi je fait mes je ne connais pas toutes les compgnie au 
nathalie rioux2248-5 boul. rene-gaultier
varennes quebec
j attends de vos nouvelle bonne ou mauvaise merci a l avance tk
 [2010-02-20 13:17 UTC] ksingla at microsoft dot com
This bug has been fixed in SVN.

In case this was a documentation problem, the fix will show up at the
end of next Sunday (CET) on

In case this was a website problem, the change will show
up on the website in short time.
Thank you for the report, and for helping us make PECL better.

PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 23:01:25 2019 UTC