final EnvironmentContext environmentContext =
context.getEnvironmentContext();
final ResponseCachingDirectives cachingDirectives =
environmentContext.getCachingDirectives();
if (cachingDirectives != null && cachingDirectives.isEnabled()) {
final Period timeToLive =
cachingDirectives.getTimeToLive();
// According to HTTp specification we treat "never expires" as "expires in approx. 1 year.
// See http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.21
final long ttl = ((Period.INDEFINITELY.equals(timeToLive))) ?
365 * 24 * 60 * 60 :
timeToLive.inSeconds() + SAFETY_THRESHOLD_FOR_MAP_ITEMS;
mediaAgent.ensureMinTimeToLive(ttl);
}
}
}