# Cache Busting Analyzer PRO

Category Severity Time To Fix
✅ Reliability Major 5 minutes

Class: Enlightn\EnlightnPro\Analyzers\Reliability\CacheBustingAnalyzer

# Introduction

This analyzer confirms that your application uses cache busting for your assets.

When a static file gets cached it can be stored for very long periods of time before it ends up expiring (depending on your browser version and cache headers if any). So, your customers might still be served stale versions of your application assets without cache busting.

Cache busting forces browsers to load fresh assets instead of serving stale copies of the code by using a unique file version identifier to tell the browser that a new version of the file is available. This is built-in with Laravel Mix.

# How To Fix

The Laravel Mix version method appends a unique hash to the filenames of all compiled files for cache busting. To fix the issue, simply add the version method to your webpack.mix.js file:

mix.js('resources/js/app.js', 'public/js')
    .version();

After generating the versioned file, you may use the mix helper method within your views to load the appropriately hashed asset:

<script src="{{ mix('/js/app.js') }}"></script>

# Skip Condition

This analyzer is skipped if your application does not use Laravel Mix.

# References