chenyahui/gin-cache

Setting HTTP on hit or miss

Closed this issue · 4 comments

Is there a way to set a http header on hit or miss?

You can use WithBeforeReplyWithCache option to custom response header.

https://github.com/chenyahui/gin-cache/blob/main/option.go#L94

I have this code

var invalidateCache cache.Option = cache.WithBeforeReplyWithCache(func(c *gin.Context, cache *cache.ResponseCache) { c.Request.Header.Set("teest", "yes") })

But it doesn't set header

Maybe it should use c.Writer.Header?

Thanks, it works like that!