Laravel和视图缓存在开发中-无法立即看到更改 [英] Laravel and view caching in development -- can't see changes right away

查看:154
本文介绍了Laravel和视图缓存在开发中-无法立即看到更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我和一些朋友决定开始一个项目,我们遇到了Laravel,并认为这可能是一个很好的工具.我们开始在本地使用它来开发我们的某些页面,并发现了一些奇怪的地方.

Some friends and I decided to start working on a project and we came across Laravel and thought it might be a good tool. We started using it locally to develop out some of our pages and noticed something strange.

当我们使用不同的信息更新视图时,将需要大约5到10分钟才能更改视图信息.就像Laravel正在缓存视图并在其上放置TTL一样.

When we update a view with different information, it would take almost 5 to 10 minutes before the views information would change. It's like Laravel is caching the view and put a TTL on it.

我知道这不是我在本地Web服务器上所做的任何事情,因为我使用过其他框架,而且从未遇到过此问题.

I know this isn't anything I am doing on my local web server because I have used other frameworks and I have never encountered this issue.

在搜索Internet时,我找不到如何禁用此功能的好答案.我想使用Laravel,但是如果每次更改时我的视图都需要花费一些时间来更新,那将毫无用处.实际上,这听起来适得其反.

Upon searching the Internet, I can't find a great answer on how to disable this. I want to use Laravel, but find it worthless if it takes a while for my views to update each time I want to make a change. In fact, it sounds counter productive.

有什么方法可以禁用此功能吗?为什么我的观点永远需要立即更新?

Is there any way to disable this? Why are my views taking forever to update right out of the box?

推荐答案

#laravel IRC频道是上帝发送的.这完全与Laravel的行为无关.这实际上是PHP 5.5正在做的事情.

The #laravel IRC channel is a God send. This had nothing to do with Laravel's behavior at all. This was actually something PHP 5.5 was doing.

之所以感到莫名其妙,是因为我从5.3升级了PHP版本,却再也没有这个问题.

The reason this was so baffling is because I upgraded my PHP version from 5.3 and never had this issue.

在您的.ini文件中,您需要调整OPcache设置.对我来说,这些设置从.ini文件中的1087行开始,看起来像这样:

In your .ini file, you need to tweak your OPcache settings. For me, these settings began at line 1087 in the .ini file and looked something like this:

opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=60
opcache.fast_shutdown=1
opcache.enable_cli=1

请特别注意opcache.revalidate_freq=60.这实际上是使视图缓存的原因.如果这不是所需的行为,请将值设置为0,并且每次进行更改时,视图都会更新.是的!

Take particular note of the opcache.revalidate_freq=60. This is what is actually making your views cache. If this is not the desired behavior, set the value to 0 and your views will update every time you make a change. Yay!

2014年8月21日修改

如下面的Matt所述,请确保重新启动Web服务器,以确保所做的更改在更改.ini文件后生效.

As mentioned by Matt below, make sure to restart your web server to see your changes take effect after you have changed your .ini file.

这篇关于Laravel和视图缓存在开发中-无法立即看到更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆