Problem
The question is pretty simple.
Is there any workaround to clear the cache like above we usually do in CLI. I am using a Bluehost shared hosting service.
Solution
You can always get SSH access, even when using shared hosting. Please contact your support and make sure to add your public SSH key to your Bluehost account using cPanel. They can give you more guidance.
However, if you want to implement something inside the application, you can always use Artisan class.
You can call an Artisan command outside the CLI.
$exitCode = Artisan::call('cache:clear');
// return what you want
});
You can check the official doc here http://laravel.com/docs/6.0/artisan#calling-commands-outside-of-cli
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.