CALL 1.800.975.6814    LIVE CHAT

@dailyrazor Blog

Laravel Clear Cache – How to Clear Cache on Views, Config, Route, etc

October 11 2018 0
Laravel Clear Cache

In this article, we’re going to take a quick look at the laravel clear cache command and its uses.

Most Laravel developers often face the issue of not seeing any change in their view. And this is compounded by the annoying “Whoops, looks like something went wrong.” error message as a resultant effect.

If you’re facing this challenge not to worry as we’re going to discuss the laravel clear cache command which can be used via Artisan in resolving this issue.

 

[SPECIAL OFFER]: 15 Days FREE Trial Linux Hosting

[BENEFITS]:

  • Expert Quality PHP Hosting on Fast Linux Server Machines!
  • FREE 1-Click App Install, Laravel, Django, Symfony, etc Frameworks Supported!
  • Multi-Domain Hosting & 99.9% Uptime Guarantee!
  • Super Fast Servers with 24/7/365 Technical Support!

Click here to access this [SPECIAL OFFER]

 

Laravel Clear Cache Overview

Laravel’s Artisan CLI enables you to clear cache not just from the view but also the route, config as well as others. However, before we get into these commands and their specifics, let’s identify key subject matters for your familiarity.

Artisan – What The Heck Is That?

In simple terms, Artisan is Laravel’s command line interface (CLI) which allows you to better manage your web application’s code. It makes laravel clear cache possible and please make sure you know what you’re doing when using Artisan so as to not break your website.

Laravel Config Cache

As you know web applications have some type of configuration file. And Laravel is no exception and introduced a modular approach to configuration files that developers love.

Imagine having different modules for each functional aspect of your Laravel web application with each module have its own config file. Now these files are stored under the config directory and having many config files can significantly slow down your Laravel web site.

With this in mind, the awesome creators of Laravel provided a mechanism to combine all these configuration files into one file thus resulting in a better performing Laravel web site.

Through Artisan you can implement this merge with a simple command:

php artisan config:cache

Boom! That’s all there it to is.

 

[SPECIAL OFFER]: 15 Days FREE Trial Linux Hosting

[BENEFITS]:

  • Expert Quality PHP Hosting on Fast Linux Server Machines!
  • FREE 1-Click App Install, Laravel, Django, Symfony, etc Frameworks Supported!
  • Multi-Domain Hosting & 99.9% Uptime Guarantee!
  • Super Fast Servers with 24/7/365 Technical Support!

Click here to access this [SPECIAL OFFER]

 

Importance of Clearing Configuration Cache

If you take a minute to study the typical Laravel configuration file, you’ll make an interesting observation of the fact that some entries in that file are could be dependent on the current server the file is on. For example, let’s say entries that deals with database names and paths, file names and paths, IP addresses, usernames, etc.

Now, let’s consider you had to migrate your Laravel web site to another server, at another host and things have changed drastically. And being the diligent person you are, you’ve taken the time to update the configuration file to reflect relevant new values.

But wait, what happens to the values stored in the cache? So you see, you have to clear the cache. In that case, just run this simple command via Artisan:

php artisan config:clear

If you don’t have the right server privileges to execute the above mentioned command (as the case with most people on Shared Hosting environments), you can simply contact the server administrator for assistance or delete the cached configure file (located at bootstrap/cache/config.php) as a workaround.

Importance of Clearing Application Cache

Furthermore, you already know that the annoying “Whoops, looks like something went wrong.” is not only caused by inconsistent configuration file entries.

So this suggests that inconsistencies can also exist within the application itself and this is where laravel clear cache at the application level comes in handy.

In such a situation, all you need to do is to perform a laravel clear cache at the application level by running the following command via Artisan:

php artisan cache:clear

 

[SPECIAL OFFER]: 15 Days FREE Trial Linux Hosting

[BENEFITS]:

  • Expert Quality PHP Hosting on Fast Linux Server Machines!
  • FREE 1-Click App Install, Laravel, Django, Symfony, etc Frameworks Supported!
  • Multi-Domain Hosting & 99.9% Uptime Guarantee!
  • Super Fast Servers with 24/7/365 Technical Support!

Click here to access this [SPECIAL OFFER]

 

Laravel Clear Cache Commands

So let’s take a quick look at important commands needed for laravel clear cache.

Laravel Reoptimize Class Loader

To reoptimize the class loader, run the following command via Artisan:

php artisan optimize

Laravel Clear Cache Facade Value

To clear the application cache facade’s value, run the following command via Artisan:

php artisan cache:clear

Laravel Clear Route Cache

Caching can also apply to the application’s route and to clear it, run the following command:

php artisan route:cache

Laravel Clear View Cache

As for the application’s view, you can clear the cache with the following command:

php artisan view:clear

Laravel Clear Config Cache

As we’ve already stated above, the application configuration cache can be cleared using the following command via Artisan:

php artisan config:cache

 

[SPECIAL OFFER]: 15 Days FREE Trial Linux Hosting

[BENEFITS]:

  • Expert Quality PHP Hosting on Fast Linux Server Machines!
  • FREE 1-Click App Install, Laravel, Django, Symfony, etc Frameworks Supported!
  • Multi-Domain Hosting & 99.9% Uptime Guarantee!
  • Super Fast Servers with 24/7/365 Technical Support!

Click here to access this [SPECIAL OFFER]

 

In Conclusion

We’ve demonstrate the several instances on how you can comfortably implement the laravel clear cache command and it’s applications toward maintaining consistency of config files, views, routes, etc.

We highly suggest you take a brief moment to study more via Laravel’s official website to better acquaint yourself with laravel clear cache. Goodluck!