开发中的 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.

在 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 和视图缓存——无法立即看到变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Difference between mt_rand() and rand()(mt_rand() 和 rand() 的区别)
Coalesce function for PHP?(PHP的合并函数?)
Fastest way to convert string to integer in PHP(在 PHP 中将字符串转换为整数的最快方法)
2 Column Mysql Date Range Search in PHP(PHP中的2列Mysql日期范围搜索)
mysql match against ~ example(mysql 匹配 ~ 示例)
How-to: Ranking Search Results(操作方法:对搜索结果进行排名)