Httpcache
An RFC7234 compliant golang http.Handler for caching HTTP responses
Install / Use
/learn @lox/HttpcacheREADME
httpcache
httpcache provides an rfc7234 compliant golang http.Handler.
Example
This example is from the included CLI, it runs a caching proxy on http://localhost:8080.
proxy := &httputil.ReverseProxy{
Director: func(r *http.Request) {
},
}
handler := httpcache.NewHandler(httpcache.NewMemoryCache(), proxy)
handler.Shared = true
log.Printf("proxy listening on http://%s", listen)
log.Fatal(http.ListenAndServe(listen, handler))
Implemented
- All of rfc7234, except those listed below
- Disk and Memory storage
- Apache-like logging via
httplogpackage
Todo
- Offline operation
- Size constraints on memory/disk cache and cache eviction
- Correctly handle mixture of HTTP1.0 clients and 1.1 upstreams
- More detail in
Viaheader - Support for weak entities with
If-MatchandIf-None-Match - Invalidation based on
Content-Locationand request method - Better handling of duplicate headers and CacheControl values
Caveats
- Conditional requests are never cached, this includes
Rangerequests
Testing
Tests are currently conducted via the test suite and verified via the CoAdvisor tool.
Reading List
- http://httpwg.github.io/specs/rfc7234.html
- https://www.mnot.net/blog/2011/07/11/what_proxies_must_do
- https://www.mnot.net/blog/2014/06/07/rfc2616_is_dead
Related Skills
node-connect
350.8kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
110.4kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
350.8kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
350.8kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
