How do I Disable the Code Cache for PHP 5 (FPM) wi

2019-03-26 04:19发布

问题:

When I save changes to a PHP file and then reload, it continues to execute the old version of the script for a minute or so regardless of how many refreshes I do. After 1 minute (or so) it executes the current version.

How do I disable this behaviour so changes occur immediately?

Setup is PHP-FPM with Nginx.

回答1:

My solution was in the Zend OPCache configuration rather than APC.

I installed the vanilla version of WNMP (PHP 5.5.11) on my Windows 8.1 box and discovered in my php.ini file's [opcache] section that the Zend OPCache was enabled and only checking file changes once every 60 seconds (opcache.revalidate_freq=60). Look for that config directive and set it to 0 to force the OPCache to check php files on each request.



回答2:

I had the same issue. My was related to APC extension caching. You can use the PHP function apc_clear_cache.



回答3:

In my case (localhost dev server, Nginx 1.10.0, PHP 7.0.13, no OPCache, no APC), setting realpath_cache_ttl to 0 and then restarting the PHP-FPM service did a trick. But one has to be careful changing this value on production server.



回答4:

using APC? check your APC section in php.ini

make sure apc.stat=1

http://www.php.net/manual/en/apc.configuration.php#ini.apc.stat