How tu run laravel php artisan serve with fresh cache - laravel

I am using php artisan serve to start my mini app on my remote server.
Once I update code, I am using ftp to upload new code.
After upload I am stop and restart (php artisan serve), but view are still "old", there is something like cache, how can I clear it?

try php artisan optimize:clear

If You want to clear file cache then you can use clearstatcache().If you are checking a file several times in a script, to avoid caching & to get correct results, use the clearstatcache() function. see more here
But if you want clear browser cache then you can delete it using headers.
see more here

Related

Laravel 5 slow refresh waiting for blocked storage access requests from trackers

I've moved a laravel app form a domain to another. All works well but I noticed, after clicked on subitting a button, that it spend 20seconds to refresh the paige. During this the system is waiting for an external components (addthis.com, google ads etc..), end when solved the process in console I read the "Blocked: Storage access requests from trackers" message.
I've setup session.php to 'same_site' => 'lax' (it was null..) but nothing happends.
Do you have some idea?
How to include safe url list as walk-artoud it ?
Thanks
Hi after this change you should clear the cache of config laravel
on your console you write :
php artisan config:clear
to permit accept the changes and then clear the cache of your application with
php artisan cache:clear
and see if this works.
I was tried with php artisan optimize:clear with no results, but as you suggest it works right, thank you a lot!
Have I repeat this periodically or only if I update session.php?

I am seeing old laravel site even after updating files

I have a website that uses vuejs as frontend and Laravel API in backend. Recently I updated my Laravel site it was working absolutely fine in my localhost. But the problem is when I upload my Laravel files to my hostinger.com hosting account it's not updating. It's displaying me old site but my database got updated and I was able to errors of the new site.
I tried these none of them seems to be working,
Cleared browser history and cache
Tried reuploading site again
I ran following commands
php artisan config:cache
php artisan route:cache
php artisan view:cache
npm run prod
Tried to use cmd command ipconfig/flushdns
Still, I was not able to solve the issue.
Have you tried refreshing your website with CTRL+F5 or CTRL+R ?

How to cache specific routes or remove from cache specific routes in Laravel?

The fact is that I am connecting to sockets from another domain and have been trying for a long time to find out why I get 419 error when connecting to a private channel. It turns out that the csrf token is cached and I can successfully connect when the routes are not cached.
I don't know of a way to be selective about it but try running:
php artisan route:cache
php artisan cache:clear
Or for the whole set of cache clears you can run php artisan optimize
The other option would be to wait out the cache expiry but I doubt you would want to do that!

laravel file is not updating

i have been working on my project for several week. everything was fine. but today all of a sudden i can not load some of my changed views (some i can change and get result). even if i change the controller, its still now working. according to SO and some other site i have tried followings
restart browser
clear browser cache, history(even tried new browser)
php artisan cache:clear
php artisan view:clear
composer dumpautoload
delete all files from storage/framework/views folder
delete all files from storage/framework/sessions folder
restart nginx server
what did i miss. thanks in advance.
Run php artisan view:clear command to clear views cache. If this won't help, delete all php files in storage/framework/views directory.
Another thing you should do is to check if you're calling the view you want. It happens in big projects with a similar views. Use Laravel Debugbar to display actually loaded views.

Blade view not reflecting changes

I am developing a Laravel(5.2.29) project in Windows environment and testing it on Chrome browser.
I have made some changes on a Blade file using atom text editor and then refreshed my page and noticed that suddenly it has stopped reflecting the changes (it's loading the old Blade file).
I've tried the following:
Restarted the browser
Clearing browser cache
Running php artisan cache:clear
Running composer dumpautoload
Deleting the Blade file (and got a view not found error). Then created a new Blade file with the same name, with no content and refreshed the page.
No matter what, the code displayed on the browser is always the same (old) version and not the content of the Blade file.
How can I solve this issue?
In order to avoid the parsing of Blade files on each reload, Laravel caches the views after Blade is processed. I've experienced some situations where the source (view file) is updated but the cache file is not "reloaded". In these cases, all you need to do is to delete the cached views and reload the page.
The cached view files are stored in storage/framework/views.
Run this command from terminal
php artisan view:clear
If you use PhpStorm, uncheck Preserve files timestamps deployment option:
https://stackoverflow.com/a/42534996/2453148
php artisan cache:clear
php artisan route:cache
php artisan config:clear
php artisan view:clear
rm -rf bootstrap/cache/*/*
Delete Cache/OPcache from PHP (fpm) of your Nginx/Apache server.
Clear the cache and clear the cached blade files:
php artisan cache:clear
php artisan config:clear
php artisan view:clear
You can also check if opcache enabled, in that case you need to clear your opcache cache.
Like Can Gelis mentionned in a comment. For me the solution was to reload PHP FPM
service php7.2-fpm reload
Alternatively if other suggested methods did not work, you can rename your files to different names. Refresh their corresponding web pages to start using new file name reference. Then you can rename the files back to your preferred names after the new pages to reflect their changes.
I have cleared all cashs and uploaded folders but didnt see changes.
Thus, if you have placed the project on a public hosting and don't have access to console then try to set deployment via your IDE (mine is phpstorm, e.g.)and set it to autoload mode. Then you'll get it working by changing something in the problem blade and by pressing cntrl+s(save) shortcut.
clear cache didn't work for me, but I just edited the file and saved it again, and it works!
None of these solutions have resolved this issue for me. Tried all php artisan options and the php code is not updating.
Only solution i've found is restarting the docker container that the code is running inside.
In case you try everything and nothing works. I recommend that you simply create a view under another name and the problem will be fixed
Example:
welcome.blade.php
change to
newview.blade.php
copy and paste code to new view
In controller just point to new view:
return view('newview');

Resources