简体   繁体   English

Laravel Views Cache如何工作?

[英]How does Laravel Views Cache works?

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

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 . 默认情况下,所有视图都是compiled/cached You can define a path where to store compiled version in app/config/view.php . 您可以在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. 当Laravel框架尝试编译视图时,它会检查源视图文件的修改日期和已编译版本(如果最后一个存在)的修改日期。 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. 如果编译的文件早于源文件,则Laravel重新编译视图并将其存储为源文件的新缓存版本。 It happens every time when you deploy a new version of the code. 每当您部署新版本的代码时,它就会发生。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM