Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make OptimizeCommand compile views #4565

Merged
merged 1 commit into from
Jun 6, 2014
Merged

Make OptimizeCommand compile views #4565

merged 1 commit into from
Jun 6, 2014

Conversation

anlutro
Copy link
Contributor

@anlutro anlutro commented Jun 3, 2014

Had this idea a while ago but dismissed it, but a request from the IRC channel reminded me of it. By making the artisan optimize command compile existing views (assuming they can be compiled) you can bring some load off your server or at the very least ensure that the first person to hit your website won't get a much slower response than the ones after him/her.

This is obviously not an issue for 99% of the framework's users, but I thought, why not?

@richardkmiller
Copy link

+1. If you run n web servers, then the first n hits of a given page take the compilation hit, assuming each web server is independent. Alternative 1 is a shared NFS mount or DRBD to share Blade templates across web servers, but that increases SPOFs and decreases robustness. Alternative 2 is to disable Blade template caching entirely (let it be generated on each page load) and assume that the file system cache and php5-fpm opcache will provide enough performance.

@Anahkiasen
Copy link
Contributor

👍

@crynobone
Copy link
Member

How would laravel then know the view is already available in compiled? We currently manage to do so with classes since the autoloader can use class_exists()

@anlutro
Copy link
Contributor Author

anlutro commented Jun 4, 2014

The compiled path is simply an md5 of the real view path, so the framework will know just as it would if the view was compiled on request. https://github.com/laravel/framework/blob/v4.2.1/src/Illuminate/View/Compilers/Compiler.php#L34-L43

taylorotwell added a commit that referenced this pull request Jun 6, 2014
@taylorotwell taylorotwell merged commit e91f016 into laravel:4.2 Jun 6, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants