opcache是个提升php性能的利器,宝塔用户直接在php扩展里面安装就行了。理论上php运行效率是可以显著提升的。当然我没有空去实际测试。最直观的就是服务器内存使用率下降了。
当然部署之后又有了新的麻烦,网站更新后私货看不到更新的东西,关闭缓存模块也一样看不到,人生在于折腾可不是吗。
对于研发环境呢我觉得不用装,装了反而麻烦事一堆。生产环境下我们就只能通过其他办法解决了。综合权衡下其实也不只是opcache有这个问题,magento自己的索引也是一样的。那么我们可以写一个快捷方法代码如下:
<h2>reindex</h2>
<?php
if($_POST['act'] == 'doreindex'){
exec("php -f /www/wwwroot/site1/shell/indexer.php reindexall");
echo 'Reindex OK!';
}
?>
<form action="reindex.php" method="post">
<input type="hidden" name="act" value="doreindex" />
<input type="submit" name="submit" value="submit" />
</form>
<h2>Opcache</h2>
<?php
if($_POST['opcache'] == 'doreindex'){
opcache_reset();
echo 'Opcache Reindex OK!';
}
?>
<form action="reindex.php" method="post">
<input type="hidden" name="opcache" value="doreindex" />
<input type="submit" name="submit" value="submit" />
</form>
每次更新完网站就刷一下就行了。
这个页面地址不要随便告诉别人,小心别有用心的人。