Laravel 5 - Clear Cache in Shared Hosting Server

Laravel 5 – Clear Cache in Shared Hosting Server

You can call an Artisan command outside the CLI.

Route::get('/clear-cache', function() {
$exitCode = Artisan::call('cache:clear');
// return what you want
});

You can check the official doc here
http://laravel.com/docs/5.0/artisan#calling-commands-outside-of-cli


Update

There is no way to delete the view cache. Neither php artisan cache:cleardoes that.

If you really want to clear the view cache, I think you have to write your own artisan command and call it as I said before, or entirely skip the artisan path and clear the view cache in some class that you call from a controller or a route.

But, my real question is do you really need to clear the view cache? In a project I'm working on now, I have almost 100 cached views and they weight less then 1 Mb, while my vendor directory is > 40 Mb. I don't think view cache is a real bottleneck in disk usage and never had a real need to clear it.

As for the application cache, it is stored in the storage/framework/cache directory, but only if you configured the file driver in config/cache.php. You can choose many different drivers, such as Redis or Memcached, to improve performances over a file-based cache.

Laravel 5.3 - Clear config cache in shared hosting

config:clear command just deletes bootstrap/cache/config.php file, so just delete this file manually.

How can I clear cache in Laravel from a hosting


 Route::get('/clear-cache', function() {
//Clear route cache:
Artisan::call('route:cache');
//Clear config cache:
Artisan::call('config:cache');
// Clear application cache:
Artisan::call('cache:clear');
// Clear view cache:
Artisan::call('view:clear');
return 'Cache cleared';
});

Try this code it will clear all cache.

How to clear Laravel route caching on server

If you want to remove the routes cache on your server, remove this file:

bootstrap/cache/routes.php

And if you want to update it just run php artisan route:cache and upload the bootstrap/cache/routes.php to your server.

Laravel 5 Clear Views Cache

There is now a php artisan view:clear command for this task since Laravel 5.1



Related Topics



Leave a reply



Submit