# Cache Header Analyzer
Category | Severity | Time To Fix |
---|---|---|
🚀 Performance | Major | 15 minutes |
Class: Enlightn\Enlightn\Analyzers\Performance\CacheHeaderAnalyzer
# Introduction
This analyzer searches for your Laravel Mix manifest file and makes requests to all assets that are versioned on Laravel Mix. We assume that the versioned assets are the ones that safe to cache, and all other assets are dynamic or un-cacheable.
If you use a CDN for your Mix assets by either setting the app.mix_url
or the app.asset_url
configuration, this analyzer makes requests to the CDN instead.
Based on the request, the analyzer checks for a Cache-Control
header. If this header does not exist, the analyzer will fail.
Caching can provide a significant performance boost for your application, especially for static assets such as images, CSS and JS files. It is recommended to enable cache control headers at the web server level or at your CDN level (if applicable).
# Skip Condition
This analyzer is skipped for local environments (if the skip_env_specific
configuration option is set to true) or if your application does not use Laravel Mix.
# References
- Nginx Caching (Servers For Hackers) (opens new window)
- Nginx Caching Guide (opens new window)
- Apache Caching Guide (opens new window)
- AWS Cloudfront Caching (opens new window)
- Cloudflare Caching (opens new window)
- Google Cloud CDN Caching (opens new window)
- Web Caching Tutorial (opens new window)
- Cache Control Header (opens new window)