package precompress
import "tailscale.com/util/precompress"
Package precompress provides build- and serving-time support for precompressed static resources, to avoid the cost of repeatedly compressing unchanging resources.
Index ¶
- func OpenPrecompressedFile(w http.ResponseWriter, r *http.Request, path string, fs fs.FS) (fs.File, error)
- func Precompress(path string, options Options) error
- func PrecompressDir(dirPath string, options Options) error
- type Options
Functions ¶
func OpenPrecompressedFile ¶
func OpenPrecompressedFile(w http.ResponseWriter, r *http.Request, path string, fs fs.FS) (fs.File, error)
OpenPrecompressedFile opens a file from fs, preferring compressed versions generated by PrecompressDir if possible.
func Precompress ¶
func PrecompressDir ¶
PrecompressDir compresses static assets in dirPath using Gzip and Brotli, so that they can be later served with OpenPrecompressedFile.
Types ¶
type Options ¶
type Options struct { // FastCompression controls whether compression should be optimized for // speed rather than size. FastCompression bool // ProgressFn, if non-nil, is invoked when a file in the directory is about // to be compressed. ProgressFn func(path string) }
Source Files ¶
precompress.go
- Version
- v1.84.0 (latest)
- Published
- May 21, 2025
- Platform
- linux/amd64
- Imports
- 11 packages
- Last checked
- 1 day ago –
Tools for package owners.