mirror of
https://github.com/kataras/iris.git
synced 2025-01-23 18:51:03 +01:00
9f85b74fc9
Former-commit-id: da4f38eb9034daa49446df3ee529423b98f9b331
21 lines
504 B
Go
21 lines
504 B
Go
package client
|
|
|
|
import (
|
|
"net/http"
|
|
"time"
|
|
|
|
"github.com/kataras/iris/cache/entry"
|
|
)
|
|
|
|
// GetMaxAge parses the "Cache-Control" header
|
|
// and returns a LifeChanger which can be passed
|
|
// to the response's Reset
|
|
func GetMaxAge(r *http.Request) entry.LifeChanger {
|
|
return func() time.Duration {
|
|
cacheControlHeader := r.Header.Get("Cache-Control")
|
|
// headerCacheDur returns the seconds
|
|
headerCacheDur := entry.ParseMaxAge(cacheControlHeader)
|
|
return time.Duration(headerCacheDur) * time.Second
|
|
}
|
|
}
|