mirror of
https://github.com/alibaba/higress.git
synced 2026-07-28 23:30:29 +08:00
fix(cache-control): emit standard max-age Cache-Control directive (#4118)
Signed-off-by: Anas Khan <83116240+anxkhn@users.noreply.github.com>
This commit is contained in:
@@ -74,7 +74,7 @@ func onHttpResponseHeaders(ctx wrapper.HttpContext, config CacheControlConfig, l
|
||||
if hit {
|
||||
if config.expires == "max" {
|
||||
proxywasm.AddHttpResponseHeader("Expires", "Thu, 31 Dec 2037 23:55:55 GMT")
|
||||
proxywasm.AddHttpResponseHeader("Cache-Control", "maxAge=315360000")
|
||||
proxywasm.AddHttpResponseHeader("Cache-Control", "max-age=315360000")
|
||||
} else if config.expires == "epoch" {
|
||||
proxywasm.AddHttpResponseHeader("Expires", "Thu, 01 Jan 1970 00:00:01 GMT")
|
||||
proxywasm.AddHttpResponseHeader("Cache-Control", "no-cache")
|
||||
@@ -83,7 +83,7 @@ func onHttpResponseHeaders(ctx wrapper.HttpContext, config CacheControlConfig, l
|
||||
currentTime := time.Now()
|
||||
expireTime := currentTime.Add(time.Duration(maxAge) * time.Second)
|
||||
proxywasm.AddHttpResponseHeader("Expires", expireTime.UTC().Format(http.TimeFormat))
|
||||
proxywasm.AddHttpResponseHeader("Cache-Control", "maxAge="+strconv.FormatInt(maxAge, 10))
|
||||
proxywasm.AddHttpResponseHeader("Cache-Control", "max-age="+strconv.FormatInt(maxAge, 10))
|
||||
}
|
||||
}
|
||||
return types.ActionContinue
|
||||
|
||||
Reference in New Issue
Block a user