How to enable ETag support for static content (CSS, JS, images, etc.)
Ask by ICSM Computer
Updated 05 Aug 2025
1. ETag Support is Handled Automatically by IIS
For static files, IIS automatically generates ETags based on file metadata (like last modified date and file size).
However, you can control behavior and enhance caching using
web.config.2. Enable/Disable ETags via IIS Settings
IIS adds headers like:
These are enabled by default unless removed via custom headers.
3. Control Cache for Static Content in
web.configYou can’t directly configure ETag values in
web.config, but you can combine ETag behavior with long-term caching:Example: Cache Static Files + Let IIS Handle ETag
This will:
Cache-Control: public, max-age=...4. Disable ETag (Optional)
If you want to remove ETags (for performance tuning or to rely only on
Cache-Control):In
web.config5. Advanced (Optional): Use Versioned URLs Instead
Another best practice is to use query string versioning or fingerprinted file names:
This makes the browser treat the URL as a "new" file if the version changes, avoiding reliance on ETag entirely.
Summary
<clientCache>inweb.configETagheader viacustomHeaders?v=...) in your markup