Bust Cache 与 Laravel 混合

Bust Cache with Laravel Mix

当我 使用 mix.version() 时,我的 CSS + JS 被缓存 - 这意味着刷新不使用最新的编译资产。然而,阅读 Laravel 的文档,他们声明如下:

Because versioned files are usually unnecessary in development, you may instruct the versioning process to only run during npm run production

https://laravel.com/docs/5.5/mix#versioning-and-cache-busting

每次我的本地文件更改时,我还能如何破坏缓存?

在 Chrome 的开发者工具中,我点击了 禁用缓存 ,它就这样做了。

Firefox: https://dzone.com/articles/how-turn-firefox-browser-cache

野生动物园:

我知道这是旧的 post。但该问题的便捷解决方案是为每个页面加载设置新请求。我通常通过在 css link.

中添加随机 ID 来处理这个问题

<link rel="stylesheet" href="{{ mix('css/app.css') . "?id=" . Str::random(16) }}">

这种方式会给你未缓存的 css,因为 link 总是变化的。