SWS provides support for arbitrary
Cache-Control HTTP header specifying
max-age response directives.
This feature is enabled by default and can be controlled by the boolean
-e, --cache-control-headers option or the equivalent SERVER_CACHE_CONTROL_HEADERS env.
Customize HTTP headers
If you want to customize HTTP headers on demand then have a look at the Custom HTTP Headers section.
Control headers are applied only to the following file types with the corresponding
max-age of one day duration is used by default.
max-age for example includes
html and other file types.
max-age of one hour is applied only to the following file types.
atom, json, rss, xml
max-age of one year is applied only to the following file types.
avif, bmp, bz2, css, doc, gif, gz, htc, ico, jpeg, jpg, js, jxl, map, mjs, mp3, mp4, ogg, ogv, pdf, png, rar, rtf, tar, tgz, wav, weba, webm, webp, woff, woff2, zip
Below is an example of how to enable the feature.
static-web-server \ --port 8787 \ --root ./my-public-dir \ --cache-control-headers true