Laravel Views Cache如何工作? [英] How does Laravel Views Cache works?

查看:157
本文介绍了Laravel Views Cache如何工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据Laravel的文档( https://laravel.com/docs/5.3/blade#introduction )视图被编译为纯PHP代码并缓存,直到对其进行修改,但是何时重新编译?

我将项目放在生产环境中,并且在部署变更时会自动显示出来,不需要清除视图缓存或类似内容.

视图是否自动重新编译(在这种情况下,何时发生?)还是没有启用缓存?

解决方案

默认情况下,所有视图均为compiled/cached.您可以在app/config/view.php中定义存储编译版本的路径.当Laravel框架尝试编译视图时,它检查源视图文件的修改日期和已编译版本(如果最后一个存在)的修改日期.如果编译的文件早于源文件,则Laravel重新编译视图并将其存储为源文件的新缓存版本.每当您部署新版本的代码时,都会发生这种情况.

According to Laravel's documentation (https://laravel.com/docs/5.3/blade#introduction) views are compiled into plain PHP code and cached until they are modified but when are they re-compiled?

I have my project in a production environment and when I deploy changes are automatically showed, I don't need to clear views cache or something similar.

Are views re-compiled automatically (in that case, when does it happen?) or do I haven't cache enabled?

解决方案

By default all views are compiled/cached. You can define a path where to store compiled version in app/config/view.php. When Laravel framework tries to compile a view it check the modification date of the source view file and compiled version if the last one exists. If the compiled file is older than a the source file Laravel recompiled the view and store it as a new cached version of the source file. It happens every time when you deploy a new version of the code.

这篇关于Laravel Views Cache如何工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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