code: func (h *Handler) freshness(res *Resource, r *cacheRequest) (time.Duration, error) {
  	maxAge, err := res.MaxAge(h.Shared)
  	if err != nil {
  		return time.Duration(0), err
  	}
  
  	if r.CacheControl.Has("max-age") {
  		reqMaxAge, err := r.CacheControl.Duration("max-age")
  		if err != nil {
  			return time.Duration(0), err
  		}
  
  		if reqMaxAge < maxAge {
  			debugf("using request max-age of %s", reqMaxAge.String())
  			maxAge = reqMaxAge
  		}
  	}
  
  	age, err := res.Age()
  	if err != nil {
  		return time.Duration(0), err
  	}
  
  	if res.IsStale() {
  		return time.Duration(0), nil
  	}
  
  	if hFresh := res.HeuristicFreshness(); hFresh > maxAge {
  		debugf("using heuristic freshness of %q", hFresh)
  		maxAge = hFresh
  	}
  
  	return maxAge - age, nil
  }
docs: // freshness returns the duration that a requested resource will be fresh for