Fix Laravel Cache & Config Issues — Changes Not Showing (2025)

Fix Laravel Cache & Config Issues — Changes Not Showing (2025)

🔁 Fix “Changes not taking effect” — Laravel Cache & Config Issues (2025)

When you change config/routes/views but Laravel still shows the old behavior, the problem is almost always cache. Laravel caches config, routes, views and other things to speed up production — but that means changes won’t appear until caches are cleared or rebuilt.

🔍 Why this happens

config:cache stores application config (including .env values) to a single PHP file — changes to .env or config/*.php won’t apply until you clear/rebuild the cache.

route:cache speeds up routing but can’t include route closures; caching routes with closures will break them.

view:cache caches compiled Blade templates.

PHP OPcache or long-running workers (queue/Octane) may still serve old code until restarted.

File permission issues can prevent Laravel from writing new cache files.

🛠 Step-by-step fixes (safe for dev & production)
1) Clear all Laravel caches (development / quick fix)

Run inside your project:

php artisan config:clear
php artisan cache:clear
php artisan route:clear
php artisan view:clear
composer dump-autoload


What this does: removes cached config, app cache, cached routes and compiled views. composer dump-autoload refreshes the autoloader after class changes.

2) Rebuild optimized caches (production)

After you’ve cleared and verified changes, rebuild optimized caches for better performance:

php artisan config:cache
php artisan route:cache
php artisan view:cache


Caution: only run route:cache if your routes do not use closures (use controller classes instead). config:cache will embed .env values — so don’t change .env afterward without clearing cache again.

3) Restart PHP (fix OPcache / workers)

If you still see old behavior, restart PHP-FPM / your queue workers / Octane:

# systemd example (Ubuntu)
sudo systemctl restart php8.2-fpm
sudo systemctl restart nginx
# restart queue workers (if using supervisor)
sudo supervisorctl restart all


Restarting ensures PHP OPcache and long-running processes load the fresh code/config.

4) Permissions & storage

Make sure Laravel can write cache files:

sudo chown -R www-data:www-data storage bootstrap/cache
sudo chmod -R 775 storage bootstrap/cache


(Replace www-data with your webserver user if different.)

5) If you changed .env

Always clear config cache after changing .env:

php artisan config:clear
# then, optionally
php artisan config:cache


If you forget, Laravel will keep using the cached env values.

🔎 Quick troubleshooting checklist

Did you run php artisan config:clear after changing .env? ✅

Are you using closures in routes/web.php? If yes — don’t use route:cache. ❌

Are queue workers or Octane running? Restart them. 🔁

Are storage and bootstrap/cache writable? ✅

Did you rebuild caches in production after the final change? ✅

🎯 Pro tips for deployment (short)

In CI/CD: clear caches → composer install → migrate → cache (config/route/view). Example sequence:

php artisan config:clear
php artisan route:clear
php artisan view:clear

composer install --no-dev --optimize-autoloader

php artisan migrate --force
php artisan config:cache
php artisan route:cache
php artisan view:cache


Use --force for migrations in automated deploys.

Avoid route:cache during active development. Use it only in production builds.

Back