Serving gzipped content for Go

后端 未结 4 2005
死守一世寂寞
死守一世寂寞 2021-01-30 17:00

I\'m starting to write server-side applications in Go. I\'d like to use the Accept-Encoding request header to determine whether to compress the response entity usi

4条回答
  •  既然无缘
    2021-01-30 17:31

    For the sake of completeness, I eventually answered my own question with a handler that is simple and specialises in solving this issue.

    • https://pkg.go.dev/github.com/rickb777/servefiles?tab=doc
    • https://github.com/rickb777/servefiles

    This serves static files from a Go http server, including the asked-for performance-enhancing features. It is based on the standard net/http ServeFiles, with gzip/brotli and cache performance enhancements.

提交回复
热议问题