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).
21 lines
701 B
Go
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) }
|