Setting HTTP on hit or miss
Closed this issue · 4 comments
allesan commented
Is there a way to set a http header on hit or miss?
chenyahui commented
You can use WithBeforeReplyWithCache option to custom response header.
https://github.com/chenyahui/gin-cache/blob/main/option.go#L94
allesan commented
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
chenyahui commented
Maybe it should use c.Writer.Header
?
allesan commented
Thanks, it works like that!