Home » Php » php – How does Laravel Views Cache works?

php – How does Laravel Views Cache works?

Posted by: admin July 12, 2020 Leave a comment


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?

How to&Answers:

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.