engine/request/static

Serve static files with optional cache + pre-gzip + validators. Engine-internal. Server cache entries store raw + gzip (base64 for cache_service JSON) plus size/mtime for ETag freshness checks. Pre-gzip entries are dropped on app reload via staticFileCache.clear(`static:${appWebPath}`). no_cache_regex (precompiled on the app) skips cache read/write; response may still gzip on the fly. Client cache: public max-age=31536000 with weak ETag (size+mtime) + Last-Modified; 304 on revalidate.
Description:
  • Serve static files with optional cache + pre-gzip + validators. Engine-internal. Server cache entries store raw + gzip (base64 for cache_service JSON) plus size/mtime for ETag freshness checks. Pre-gzip entries are dropped on app reload via staticFileCache.clear(`static:${appWebPath}`). no_cache_regex (precompiled on the app) skips cache read/write; response may still gzip on the fly. Client cache: public max-age=31536000 with weak ETag (size+mtime) + Last-Modified; 304 on revalidate.

Methods

(inner) etagMatch(a, b) → {boolean}

Description:
  • Weak ETag comparison (strip W/ prefix and quotes for compare).
Parameters:
Name Type Description
a string
b string
Returns:
Type
boolean

(inner) gzipBuffer(data) → {Promise.<(Buffer|null)>}

Parameters:
Name Type Description
data Buffer
Returns:
Type
Promise.<(Buffer|null)>

(inner) httpDate(mtime) → {string}

Parameters:
Name Type Description
mtime Date | number
Returns:
HTTP-date
Type
string

(inner) isNotModified(req, etag, lastModified) → {boolean}

Parameters:
Name Type Description
req object
etag string
lastModified string
Returns:
Type
boolean

(inner) serveDirectoryOr404()

Description:
  • Directory index redirect or 404.

(async, inner) serveStaticFile(opts) → {Promise.<boolean>}

Parameters:
Name Type Description
opts object
Returns:
true if this handler owns the response (caller should stop)
Type
Promise.<boolean>

(inner) validatorsFromStat(stat) → {Object}

Parameters:
Name Type Description
stat object fs.Stats-like
Returns:
Type
Object

(inner) weakEtag(size, mtimeMs) → {string}

Description:
  • Weak ETag from size + mtimeMs.
Parameters:
Name Type Description
size number
mtimeMs number
Returns:
Type
string