Cache Headers
Checks Cache-Control header configuration
Checks Cache-Control header configuration
| Rule ID | perf/cache-headers |
| Category | Performance |
| Scope | Per-page |
| Severity | warning |
| Weight | 4/10 |
Solution
Use Cache-Control headers to enable browser caching. For static assets (CSS, JS, images), set long max-age (1 year) with immutable when using hashed filenames. For HTML, use shorter max-age or no-cache with revalidation. Example: ‘Cache-Control: public, max-age=31536000, immutable’ for versioned assets.
Options
This rule supports the following configuration options:
| Option | Type | Default | Description |
|---|---|---|---|
min_static_max_age | unknown | undefined | Minimum max-age for static assets in seconds (1 day) |
Configuration Example
squirrel.toml
toml[rules."perf/cache-headers"]
min_static_max_age = undefinedEnable / Disable
Disable this rule
squirrel.toml
toml[rules]
disable = ["perf/cache-headers"]Disable all Performance rules
squirrel.toml
toml[rules]
disable = ["perf/*"]Enable only this rule
squirrel.toml
toml[rules]
enable = ["perf/cache-headers"]
disable = ["*"]