// GetMaxAgeFromHeader returns the max-age value from the cache-control header, defaulting to 1800.
GetMaxAgeFromHeader returns the max-age value from the cache-control header, defaulting to 1800.
// GetMaxAgeFromHeader returns the max - age value from the cache - control header defaulting to 1800 .
func GetMaxAgeFromHeader(header http.Header) time.Duration {
	maxAge := time.Duration(1800)
	cacheControl := header.Get("cache-control")
	if cacheControl != "" {
		matches := rgxMaxAge.FindStringSubmatch(cacheControl)
		if len(matches) > 1 {
			foundMaxAge, err := strconv.ParseInt(matches[1], 10, 64)
			if err == nil {
				maxAge = time.Duration(foundMaxAge)
			} else {
				logger.Error("could not parse int", zap.String("in", matches[1]), zap.Error(err))
			}
		}
	}
	return maxAge * time.Second
}
func GetMaxAgeFromHeader ( header http . Header ) time . Duration { maxAge := time . Duration ( 1800 ) cacheControl := header . Get ( " " ) if cacheControl != " " { matches := rgxMaxAge . FindStringSubmatch ( cacheControl ) if len ( matches ) > 1 { foundMaxAge , err := strconv . ParseInt ( matches [ 1 ] , 10 , 64 ) if err == nil { maxAge = time . Duration ( foundMaxAge ) } else { logger . Error ( " " , zap . String ( " " , matches [ 1 ] ) , zap . Error ( err ) ) } } } return maxAge * time . Second }
GetMaxAgeFromHeader returns the max-age value from the cache-control header, defaulting to 1800.
GetMaxAgeFromHeader returns the max - age value from the cache - control header defaulting to 1800 .