diff --git a/benchmark/baremetal.sh b/benchmark/baremetal.sh index 504920e..deb8c37 100755 --- a/benchmark/baremetal.sh +++ b/benchmark/baremetal.sh @@ -179,13 +179,13 @@ main() { NAMES=("static-web (preload+gc400)" "Bun") # ====================================================================== - # Test 1: static-web --preload --gc-percent 400 (production mode) + # Test 1: static-web --preload --gc-percent 400 --no-etag (production mode) # ====================================================================== echo -e "${BOLD}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${RESET}" - echo -e "${BOLD} [ static-web — production: --preload --gc-percent 400 ]${RESET}" + echo -e "${BOLD} [ static-web — production: --preload --gc-percent 400 --no-etag ]${RESET}" echo -e "${BOLD}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${RESET}" - "$BIN" --quiet --no-compress --preload --gc-percent 400 --port "$PORT" "$abs_root" & + "$BIN" --quiet --no-compress --no-etag --preload --gc-percent 400 --port "$PORT" "$abs_root" & SERVER_PID=$! sleep "$SETTLE_SECONDS" wait_for_port "$PORT" diff --git a/cmd/static-web/main.go b/cmd/static-web/main.go index 946d31d..692df00 100644 --- a/cmd/static-web/main.go +++ b/cmd/static-web/main.go @@ -101,6 +101,9 @@ func runServe(args []string) { // Compression. noCompress := fs.Bool("no-compress", false, "disable response compression") + // Headers. + noEtag := fs.Bool("no-etag", false, "disable ETag generation and If-None-Match validation") + // Security. cors := fs.String("cors", "", "allowed CORS origins, comma-separated or * for all") dirListing := fs.Bool("dir-listing", false, "enable directory listing") @@ -150,6 +153,7 @@ func runServe(args []string) { preload: *preload, gcPercent: *gcPercent, noCompress: *noCompress, + noEtag: *noEtag, cors: *cors, dirListing: *dirListing, noDotfileBlock: *noDotfileBlock, @@ -249,6 +253,7 @@ type flagOverrides struct { preload bool gcPercent int noCompress bool + noEtag bool cors string dirListing bool noDotfileBlock bool @@ -319,6 +324,11 @@ func applyFlagOverrides(cfg *config.Config, f flagOverrides) error { cfg.Compression.Enabled = false } + // Headers. + if f.noEtag { + cfg.Headers.EnableETags = false + } + // Security. if f.cors != "" { parts := strings.Split(f.cors, ",") diff --git a/docs/fonts.css b/docs/fonts.css new file mode 100644 index 0000000..4a1a758 --- /dev/null +++ b/docs/fonts.css @@ -0,0 +1,61 @@ +/* =========================== + Local Fonts - Self-hosted + =========================== */ + +/* Outfit - Sans-serif for all text */ +@font-face { + font-family: 'Outfit'; + font-style: normal; + font-weight: 400; + font-display: swap; + src: url('fonts/outfit-400.woff2') format('woff2'); +} + +@font-face { + font-family: 'Outfit'; + font-style: normal; + font-weight: 500; + font-display: swap; + src: url('fonts/outfit-500.woff2') format('woff2'); +} + +@font-face { + font-family: 'Outfit'; + font-style: normal; + font-weight: 600; + font-display: swap; + src: url('fonts/outfit-600.woff2') format('woff2'); +} + +@font-face { + font-family: 'Outfit'; + font-style: normal; + font-weight: 700; + font-display: swap; + src: url('fonts/outfit-700.woff2') format('woff2'); +} + +@font-face { + font-family: 'Outfit'; + font-style: normal; + font-weight: 800; + font-display: swap; + src: url('fonts/outfit-800.woff2') format('woff2'); +} + +/* Fira Code - Monospace for source code and configs */ +@font-face { + font-family: 'Fira Code'; + font-style: normal; + font-weight: 400; + font-display: swap; + src: url('fonts/firacode-400.woff2') format('woff2'); +} + +@font-face { + font-family: 'Fira Code'; + font-style: normal; + font-weight: 500; + font-display: swap; + src: url('fonts/firacode-500.woff2') format('woff2'); +} diff --git a/docs/fonts/firacode-400.woff2 b/docs/fonts/firacode-400.woff2 new file mode 100644 index 0000000..ed70084 Binary files /dev/null and b/docs/fonts/firacode-400.woff2 differ diff --git a/docs/fonts/firacode-500.woff2 b/docs/fonts/firacode-500.woff2 new file mode 100644 index 0000000..ed70084 Binary files /dev/null and b/docs/fonts/firacode-500.woff2 differ diff --git a/docs/fonts/outfit-400.woff2 b/docs/fonts/outfit-400.woff2 new file mode 100644 index 0000000..85e3332 Binary files /dev/null and b/docs/fonts/outfit-400.woff2 differ diff --git a/docs/fonts/outfit-500.woff2 b/docs/fonts/outfit-500.woff2 new file mode 100644 index 0000000..85e3332 Binary files /dev/null and b/docs/fonts/outfit-500.woff2 differ diff --git a/docs/fonts/outfit-600.woff2 b/docs/fonts/outfit-600.woff2 new file mode 100644 index 0000000..85e3332 Binary files /dev/null and b/docs/fonts/outfit-600.woff2 differ diff --git a/docs/fonts/outfit-700.woff2 b/docs/fonts/outfit-700.woff2 new file mode 100644 index 0000000..85e3332 Binary files /dev/null and b/docs/fonts/outfit-700.woff2 differ diff --git a/docs/fonts/outfit-800.woff2 b/docs/fonts/outfit-800.woff2 new file mode 100644 index 0000000..85e3332 Binary files /dev/null and b/docs/fonts/outfit-800.woff2 differ diff --git a/docs/index.html b/docs/index.html index 82addb0..d0ddce8 100644 --- a/docs/index.html +++ b/docs/index.html @@ -6,7 +6,7 @@
~141k req/sec — 55% faster than Bun. Built on fasthttp with direct ctx.SetBody() and pre-formatted headers — no formatting allocations on cache hits.
~148k req/sec — 59% faster than Bun. Built on fasthttp with direct ctx.SetBody() and pre-formatted headers — no formatting allocations on cache hits.
Byte-accurate LRU cache with startup preloading, configurable max size, per-file size cap, optional TTL expiry, ETag, and live flush via SIGHUP without downtime.
+Byte-accurate LRU cache with startup preloading, configurable max size, per-file size cap, optional TTL expiry, optional ETag (disable via --no-etag), and live flush via SIGHUP without downtime.
- Full HTTP/2 support, byte-range serving for video / large files, conditional requests (ETag, + Full HTTP/2 support, byte-range serving for video / large files, conditional requests (optional ETag via --no-etag to disable, If-Modified-Since, 304).
- With fasthttp + preload, static-web reaches ~141k req/sec — 55% faster than Bun at ~90k req/sec, while offering full security headers, TLS, and compression out of the box. + With fasthttp + preload, static-web reaches ~148k req/sec — 59% faster than Bun at ~93k req/sec, while offering full security headers, TLS, and compression out of the box.