Fredrik
Fredrik

Reputation: 3283

Bust Cache with Laravel Mix

When I don't use mix.version(), my CSS + JS is cached - meaning a refresh does not use newest compiled assets. However, reading Laravel's docs, they state the following:

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

How else would I bust the cache every time my local files changes?

Upvotes: 3

Views: 4901

Answers (2)

Gerald
Gerald

Reputation: 21

I know this is old post. But the convenient solution for the problem is to set new request for every page load. i usually handle this by adding random id in css link.

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

this way will give you uncached css, because the link is always change.

Upvotes: 1

Fredrik
Fredrik

Reputation: 3283

In the Developer Tools in Chrome, I clicked Disable Cache, and it did just that.

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

Safari: How do I disable cache in Safari 11.0?

Upvotes: -1

Related Questions