首页 > 解决方案 > Clear cache everytime for changes to show

问题描述

Using laravel/homestead for developing an application

Expected Outcome: When making changes on JS file, for example adding console.log for debugging, change also effects local files and when reloading browser page change is reflected.

Reality: When I add console.log or any change to my JS file located in public/js, the changes do not show when I reload page. I have to clear the browser's cache (History > delete cache) every time to see the changes reflect in my browser or Chrome developer console.

Clearly, this is inconvenient.

Context: I am ssh in my vagrant's vm from this project and running php artisan serve to run the application - localhost:8000. My project has laravel/homestead installed separtaly from ~/Homestead. Are my folders not in sync from the global ~/Homestead even though homestead is installed in this project locally?

标签: laravelvagranthomestead

解决方案


Chrome has an option to disable the cache while developer tools are open. Right now it's probably not requesting your modified js files, and is instead hitting its internal cache.

  1. Open developer tools (F12 or Right clickinspect)
  2. Open the Network tab
  3. Check Disable cache

This setting will only apply while dev tools are open.

As a side note, if you're using the front end scaffolding provided by Laravel Mix, you shouldn't be editing files in your public/ folder because they'll be overwritten during build.


推荐阅读