You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Laravel如何清除缓存?解决mix引入CSS修改后不生效问题

Hey there! Let's break down your Laravel questions and fix those issues step by step.

在Laravel中清除缓存的方法

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:clear
    
  • Clear route cache:
    If you've made changes to your routes, you need to clear the route cache:

    php artisan route:clear
    
  • Clear config cache:
    After modifying configuration files, remember to clear the config cache:

    php artisan config:clear
    
  • Clear view cache:
    You can clear the compiled Blade view cache files with this command:

    php artisan view:clear
    
  • Clear all caches at once:
    If you want to clear all types of cache in one go, use this command:

    php artisan optimize:clear
    
解决Mix生成的CSS文件更新不生效问题

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:

  1. Recompile front-end resources
    After modifying app.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
      
  2. Manually clear Mix's Manifest file
    Mix stores hash values in the public/mix-manifest.json file. 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.

  3. 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.
  4. Additional checks for production environments
    If you're on a production server, make sure:

    • You ran npm run prod to recompile resources during deployment
    • Server-side static resource caches (like Nginx cache rules or CDN caches) have also been cleared

内容的提问来源于stack exchange,提问作者Er. Mukesh Sharma

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 04:21:24