Files
magpie/internal/gui/dev_off.go
T
yetone 5f5307ab6d gui: each embedded file is hashed once, not on every load
revalidated read each embedded file again on every request to make its
ETag, and the page "/" read and hashed every file it names to version
their URLs. A release's files never change, so each one's sum (and the
versioned page) is now kept in a sync.Map after its first read. A dev
build (-tags dev) reads from disk and keeps nothing.

Measured: TestStaticFilesHashedOnce, 20 loads each, on mote:
  with the memo   green (app.js under 1x its size, page under 6x its)
  memo off by hand  app.js 26,516,856 B; page 165,916,424 B (~8 MB a
                    page load) - red
Run on mote: go vet ./internal/gui and -tags dev; go test -run
"StaticFilesHashedOnce|VersionedFilesKept|WebCompresses|PageFilesRevalidate|Revalidat"
./internal/gui ok.
Not tried: the full GUI suite (no change to what is served).
2026-11-13 05:31:22 +08:00

21 lines
701 B
Go

//go:build !dev
package gui
import (
"io/fs"
"net/http"
)
// staticFixed: the UI's files are the binary's, the same for its life.
const staticFixed = true
// The shipped app serves the UI from the binary, in one process.
func staticFS() fs.FS { f, _ := fs.Sub(assets, "assets"); return f }
func devRoutes(*http.ServeMux) {}
func devListen(http.Handler) {}
func devPage(h http.Handler) http.Handler { return h }
func devRole() string { return "" }
func devBackend(func(Windows) http.Handler) error { return nil }
func stash(link string) string { return stashImport(link) }