問題描述
我和一些朋友決定開始一個項目,我們遇到了 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 提到的,確保在更改 .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 和視圖緩存——無法立即看到變化的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!