Cache-Control: immutable is a 2017 addition to HTTP caching that browsers treat as “do not even send a conditional revalidation, this URL never changes”. For hashed asset filenames — app.a1b2c3.css, vendor.def456.js — that is exactly the right semantics. A repeat visitor never even asks the server about the file again; the browser serves from local cache instantly. On cPanel, the header is easy to set; the prerequisite is hashed filenames, which most WordPress builds do not produce by default.
What’s happening
The standard Cache-Control: max-age=31536000 tells the browser “do not refetch for a year”. But browsers still issue a conditional If-Modified-Since or If-None-Match revalidation when the user explicitly refreshes (Cmd-R / Ctrl-R). That revalidation is a 304 round-trip the user does not see, but it is still latency.
Cache-Control: immutable adds: “I promise this URL’s content never changes. Do not even revalidate.” For hashed filenames, this is true by construction — if the content changes, the filename’s hash changes, and the URL is a different URL. Browsers that understand immutable (Firefox since 49, Chrome since 89, Safari since 11) skip the revalidation entirely.
How to verify
Check current headers on a built asset:
curl -I https://example.com/wp-content/themes/site/build/main.a1b2c3.css
curl -I https://example.com/wp-content/themes/site/style.css
Want to see: cache-control: public, max-age=31536000, immutable on the hashed file. For non-hashed (like the WordPress theme style.css), immutable is wrong because the file content can change without the URL changing.
Confirm the build produces hashed filenames:
ls /home/<user>/public_html/wp-content/themes/site/build/
# Should see: main.a1b2c3.css, vendor.def456.js, etc.
# Not just: main.css, vendor.js
If the build does not produce hashes, the customer’s deploy pipeline needs adjustment — webpack, vite, parcel all support hashed output. Without hashes, do not use immutable.
The fix
In .htaccess (or /etc/apache2/conf.d/userdata/... for a fleet):
<IfModule mod_headers.c>
<FilesMatch "\.[a-f0-9]{6,12}\.(css|js|woff2|jpg|jpeg|png|webp|avif)$">
Header set Cache-Control "public, max-age=31536000, immutable"
</FilesMatch>
<FilesMatch "^(style|app|main)\.(css|js)$">
Header set Cache-Control "public, max-age=300"
</FilesMatch>
</IfModule>
The first FilesMatch only catches files with a 6-12 character hex hash before the extension. Adjust the regex to match your build’s hash style.
For LiteSpeed, the same directives work because LSWS honors .htaccess. For a more programmatic setup, configure in the LSWS vhost config.
After deploying, verify with curl -I against both a hashed and a non-hashed file. The repeat-visit experience should be measurably faster — the network tab shows “memory cache” or “disk cache” instead of 304 round-trips.
For CDN-fronted sites, the CDN will honor and forward the immutable header. Cloudflare’s edge cache treats immutable as authoritative; the cache hit ratio jumps. Stack Harbor sets immutable headers as part of deployment management.