暂时禁用OPCache
问题描述:
我最近转移到PHP 5.4并安装了OPCache,它非常强大!
I recently moved to PHP 5.4 and installed OPCache, it's very powerful!
如何临时禁用缓存?
我尝试过:
ini_set('opcache.enable', 0);
但是没有效果.
谢谢
答
脚本一旦运行,就已经太晚了,不能缓存文件了.您需要在PHP外部进行设置:
Once your script runs, it's too late to not cache the file. You need to set it outside PHP:
-
如果PHP作为Apache模块运行,请使用
.htaccess
文件:
php_flag opcache.enable Off
如果PHP作为CGI/FastCGI运行,请使用.user.ini
文件:
opcache.enable=0
而且,在任何情况下,如果可以访问,您都可以使用旧的系统范围的php.ini
.
And, in any case, you can use good old system-wide php.ini
if you have access to it.