Laravel如何清除缓存?解决mix引入CSS修改后不生效问题
Hey there! Let's break down your Laravel questions and fix those issues step by step.
Laravel has several types of caches, and you can clear them individually or all at once based on your needs:
Clear application cache:
Run this command to clear the general application cache:php artisan cache:clearClear route cache:
If you've made changes to your routes, you need to clear the route cache:php artisan route:clearClear config cache:
After modifying configuration files, remember to clear the config cache:php artisan config:clearClear view cache:
You can clear the compiled Blade view cache files with this command:php artisan view:clearClear all caches at once:
If you want to clear all types of cache in one go, use this command:php artisan optimize:clear
The id=43965480df345823e8e0 is a version hash generated by Laravel Mix, used for cache busting—when the file content changes, the hash updates, forcing the browser to load the new file instead of using local cache. If your modified CSS isn't showing up, it's likely because the resources weren't recompiled or caches weren't cleared properly. Here are the fixes:
Recompile front-end resources
After modifyingapp.css, you need to re-run the Mix compilation command to generate a new hash:- For development (supports hot reloading, auto-compiles on changes):
npm run watch - Quick compilation for development:
npm run dev - For production (minifies and optimizes resources):
npm run prod
- For development (supports hot reloading, auto-compiles on changes):
Manually clear Mix's Manifest file
Mix stores hash values in thepublic/mix-manifest.jsonfile. If this file isn't updated, the URL path won't change either. You can delete this file directly, then re-run the compilation command above—Mix will automatically generate a new manifest file.Force refresh browser cache
Sometimes browsers stubbornly cache old files. Use these shortcuts to force a refresh:- Windows/Linux:
Ctrl + Shift + R - Mac:
Cmd + Shift + R
Alternatively, check the "Disable cache" option in your browser's developer tools (F12) while keeping the tools open—this prevents resource caching during development.
- Windows/Linux:
Additional checks for production environments
If you're on a production server, make sure:- You ran
npm run prodto recompile resources during deployment - Server-side static resource caches (like Nginx cache rules or CDN caches) have also been cleared
- You ran
内容的提问来源于stack exchange,提问作者Er. Mukesh Sharma

