Cache-Control Headers
SWS provides support for arbitrary Cache-Control HTTP header specifying public and 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.
Cache-Control
Control headers are applied only to the following file types with the corresponding max-age values or no-cache directive (default).
no-cache (default)
A no-cache directive is used by default.
Note
no-cache applies to for example HTML, JSON and other file types.
One hour
A max-age of one hour is applied only to the following file types.
atom, rssOne year
A 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, zipError responses
The file type max-age values apply only to successful (2xx) and 304 Not Modified responses. Other file responses, such as a 404 Not Found for a missing /app.css, get the no-cache directive.
With a fallback page configured, a GET for a missing file is answered with 200 OK and the fallback page, so it still gets the file type max-age value.
Below is an example of how to enable the feature.
static-web-server --port 8787 --root ./public --cache-control-headers