config:cache and optimize

Artisan commands that merge settings, routes and views into fast cached files for production.

Also called: cache:clear, optimize:clear, route:cache

Source
General
Language
PHP

In plain English

After changing .env on the server, run them again; otherwise the old values stay cached. optimize:clear removes every cache when something behaves strangely.

Example

I changed .env on the server but forgot to run config:cache, so nothing changed.

In code

php artisan optimize          # config, routes, views
php artisan optimize:clear

Learn more

Related terms

Added 2026-11-30 · Last reviewed 2026-11-30