php artisan view:clear
php artisan cache:clear
php artisan route:clear
php artisan config:clear
php artisan optimize
//Laravel 7 / 2021-01
php artisan cache:clear
php artisan route:clear
php artisan config:clear
php artisan optimize
// Keep life simple :)
sail artisan optimize:clear
or
php artisan optimize:clear
// Output: Cached events cleared!
"
Compiled views cleared!
Application cache cleared!
Route cache cleared!
Configuration cache cleared!
Compiled services and packages files removed!
Caches cleared successfully!
"
php artisan view:clear
php artisan config:clear
php artisan route:clear
php artisan cache:clear
php artisan clear-compiled
/** Clear all cache Laravel **/
php artisan route:clear && php artisan view:clear && php artisan config:clear && php artisan cache:clear && php artisan clear-compiled
$ php artisan view:clear
$ php artisan config:clear
$ php artisan route:clear
$ php artisan cache:clear
$ php artisan clear-compiled
public function index() {
$minutes = 1440; # 1 day
$posts = Cache::remember('posts', $minutes, function () {
return Post::get();
});
return $posts;
}
//we can use this route by only single click from admin panel or by accessing url
Route::get('/cache/clear', function() {
Artisan::call('cache:clear');
Artisan::call('config:clear');
Artisan::call('route:clear');
Artisan::call('view:clear');
return redirect()->route('admin.dashboard')->with('cache','System Cache Has Been Removed.');
})->name('admin-cache-clear');
#Or if any one want to clear cache from command then:-
/** Clear all cache Laravel **/
php artisan route:clear &&
php artisan view:clear &&
php artisan config:clear &&
php artisan cache:clear &&
php artisan clear-compiled
/** Short **/
php artisan optimize:clear //for all clear in a single command
php artisan config:cache && php artisan config:clear && composer dump-autoload -o
Cache::put('key', 'value', $seconds);
Cache::rememberForever('users', function () {
return DB::table('users')->get();
});
Cache::get('key');
Cache::has('key');
Cache::pull('key');
// i am using laravel versioin 8 so......
// use this in ur controller then
use IlluminateSupportFacadesCache;
// in function
Cache::put('key', 'value', 1440);// 1 day
Cache::get('key');
Cache::has('key');
Cache::pull('key');
Cache::forget('key');// remove spacific
Cache::flush(); // remove all
// cache clear in Laravel
php artisan config:cache
php artisan cache:clear
php artisan view:clear
// optional
php artisan route:clear
use IlluminateSupportFacadesCache;