1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-17 09:57:01 +00:00

improve cache handler, embracing #2210 too

This commit is contained in:
Gerasimos (Makis) Maropoulos
2023-09-26 21:14:57 +03:00
parent d03757b996
commit 28f49cd50d
17 changed files with 381 additions and 216 deletions

View File

@@ -29,6 +29,10 @@ func main() {
app := iris.New()
app.Logger().SetLevel("debug")
app.Get("/", cache.Handler(10*time.Second), writeMarkdown)
// To customize the cache handler:
// cache.Cache(nil).MaxAge(func(ctx iris.Context) time.Duration {
// return time.Duration(ctx.MaxAge()) * time.Second
// }).AddRule(...).Store(...)
// saves its content on the first request and serves it instead of re-calculating the content.
// After 10 seconds it will be cleared and reset.