I am working on Nginx server, with PHP-FPM. I installed Laravel 4.1
and bootstrap v3.1.1.
, and here is the problem. For the last 30 minutes, I have been trying to change a css rule that I first declared to check boostrap.
.jumbotron{
background: red;
}
The first time it worked. The jumbotron container was red. So, I removed that css value and started working, but still no matter which browse I use, the container is red. I even checked the css file through the Google Chromes inspection tool, and it is showing me that first value when jumbotron had a background:red
. I deleted the css file and renamed it and add new styles, I configured chrome not to cache pages. But Still the same value. I'm convinced now, that Laravel has kept a cache of the first style declaration.
Is there any way to disable this at all?
Same issue here. I am using VirtualBox with Shared Folders pointing to my document root.
This pointed me in the right direction: https://stackoverflow.com/a/26583609/1036602
Which led me to this: http://www.danhart.co.uk/blog/vagrant-virtualbox-modified-files-not-updating-via-nginx-apache
and this: https://forums.virtualbox.org/viewtopic.php?f=1&t=24905
If you're mounting your local dev root via vboxsf Shared Folders, set EnableSendFile Off in your apache2.conf (or sendfile off if using Nginx).
General explanation
When you access a Laravel Blade view, it will generate it to a temporary file so it doesn't have to process the Blade syntax every time you access to a view. These files are stored in
app/storage/view
with a filename that is the MD5 hash of the file path.Usually when you change a view, Laravel regenerate these files automatically at the next view access and everything goes on. This is done by comparing the modification times of the generated file and the view's source file through the
filemtime()
function. Probably in your case there was a problem and the temporary file wasn't regenerated. In this case, you have to delete these files, so they can be regenerated. It doesn't harm anything, because they are autogenerated from your views and can be regenerated anytime. They are only for cache purposes.Normally, they should be refreshed automatically, but you can delete these files anytime if they get stuck and you have problems like these, but as I said these should be just rare exceptions.
Code break down
All the following codes are from
laravel/framerok/src/Illuminate/View/
. I added some extra comments to the originals.Get view
Starting from
Engines/CompilerEngine.php
we have the main code we need to understand the mechanics.Check if regeneration required
This will be done in
Compilers/Compiler.php
. This is an important function. Depending on the result it will be decided whether the view should be recompiled. If this returnsfalse
instead oftrue
that can be a reason for views not being regenerated.Regenerate view
If the view is expired it will be regenerated. In
Compilers\BladeCompiler.php
we see that the compiler will loop through all Blade keywords and finally give back a string that contains the compiled PHP code. Then it will check if the view storage path is set and save the file there with a filename that is the MD5 hash of the view's filename.Evaluate
Finally in
Engines/PhpEngine.php
the view is evaluated. It imports the data passed to the view withextract()
andinclude
the file with the passed path in atry
andcatch
all exceptions withhandleViewException()
that throws the exception again. There are some output buffering too.For what it's worth and because this answer came up first in my google search...
I had the same problem. The CSS and JS files wouldn't update. Deleting the cache files didn't work. The timestamps were not the problem. The only way I could update them was to change the filename, load it directly to get the 404 error, and then change the name back to the original name.
In the end the problem was not related to Laravel or the browser cache at all. The problem was due to NginX using sendfile which doesn't work with remote file systems. In my case, I was using VirtualBox for the OS and the remote file system was vboxsf through Guest Additions.
I hope this saves someone else some time.