Php – Laravel 5 – Clear Cache in Shared Hosting Server


The question is pretty clear.

php artisan cache:clear

Is there any workaround to clear the cache like the above command but without using CLI. I am using a popular shared hosting service, but as per my plan, I don't have control panel access.

I want to clear the views cache.

I saw a question almost the same like this, but it doesn't help me.

Best Solution

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


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.

Related Question