Skip to content

mkio 1.6.0

Latest

Choose a tag to compare

@markuskimius markuskimius released this 20 Sep 20:59

mkio 1.6.0 stops browsers serving stale files. mkio's files went out with ETag and Last-Modified but no Cache-Control, so a browser chose a lifetime itself — typically a tenth of the file's age — and reused its copy without asking: an old stylesheet for days after a deploy, an old /mkio.js against a new server after pip install -U mkio. A minor release: one new config key and one new route form. No change to the wire protocol, the CLI, the clients, the expression language or the on-disk layout.

Changed

  • Every HTTP response now carries Cache-Control: no-cache unless its handler set a Cache-Control of its own — [static] and [config] files, the index page, /mkio.js, /mkio-expr.js, the API. The browser still stores the file; it revalidates on each use, and the validators make that a bodyless 304. WebSocket handshakes are left alone.

Added

  • cache_control (top-level, default "no-cache") sets the value for the whole server. cache_control = "" sends no header — the behaviour before this release. Checked at load: a string with no control characters.

  • A [static] or [config] route may be a table in place of the directory, overriding the global value for the files it serves:

    [static]
    "/" = "./static"
    "/assets" = { path = "./dist/assets", cache_control = "public, max-age=31536000, immutable" }
    
    [config]
    "/config" = { path = "./configs", cache_control = "no-store" }

    With "/" the value covers the index page and /static/*. It is not applied to the route's errors: a 404 under /assets goes out with the global value, so a missing file is not remembered for a year. The plain string form is unchanged. Long lifetimes are for fingerprinted file names only; anything under a stable name, index.html above all, should stay on no-cache.

Precedence: the handler's own header, then the route, then the global key.

See the README section "HTTP caching".