沃梦达 / 编程问答 / php问题 / 正文

开发中的 Laravel 和视图缓存 - 无法立即看到更改

Laravel and view caching in development -- can#39;t see changes right away(开发中的 Laravel 和视图缓存 - 无法立即看到更改)

本文介绍了开发中的 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.

在互联网上搜索时,我找不到有关如何禁用此功能的好答案.我想使用 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 和视图缓存 - 无法立即看到更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:开发中的 Laravel 和视图缓存 - 无法立即看到更改

基础教程推荐