https://github.com/2manymws/rc
rc is a response cache middleware for cache.
https://github.com/2manymws/rc
go http-middleware response-cache rfc9111
Last synced: 23 days ago
JSON representation
rc is a response cache middleware for cache.
- Host: GitHub
- URL: https://github.com/2manymws/rc
- Owner: 2manymws
- License: mit
- Created: 2023-09-04T07:04:42.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2026-03-01T03:17:51.000Z (about 2 months ago)
- Last Synced: 2026-03-01T06:35:38.749Z (about 2 months ago)
- Topics: go, http-middleware, response-cache, rfc9111
- Language: Go
- Homepage:
- Size: 245 KB
- Stars: 5
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# rc [](https://pkg.go.dev/github.com/2manymws/rc) [](https://github.com/2manymws/rc/actions/workflows/ci.yml)   
`rc` is a **r**esponse **c**ache middleware for cache.
## Usage
Prepare an instance that implements [`rc.Casher`](https://pkg.go.dev/github.com/2manymws/rc#Cacher) interface.
Then, generate the middleware ( `func(next http.Handler) http.Handler` ) with [`rc.New`](https://pkg.go.dev/github.com/2manymws/rc#New)
```go
package main
import (
"log"
"net/http"
"github.com/2manymws/rc"
)
func main() {
r := http.NewServeMux()
r.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("Hello World"))
})
var c rc.Cacher = newMyCacher()
m := rc.New(c)
log.Fatal(http.ListenAndServe(":8080", m(r)))
}
```
## Utility functions
See https://github.com/2manymws/rcutil