if (response instanceof RevalidateMarkupResponse && cachedContent != null)
{
// Normally we receive such response when the validation token was set which implies we have an existing content
// We substitute with the appropriate content response
RevalidateMarkupResponse revalidate = (RevalidateMarkupResponse)response;
CacheControl control = revalidate.getCacheControl();
if (cachedContent instanceof FragmentResponse)
{
response = new FragmentResponse((FragmentResponse)cachedContent, control);
}
else
{
response = new ContentResponse(cachedContent, control);
}
}
// If we have a content cache it whenever it is possible
if (response instanceof ContentResponse)
{
ContentResponse contentResponse = (ContentResponse)response;
CacheControl control = contentResponse.getCacheControl();
//
if (control != null)
{
// Compute expiration time, i.e when it will expire
long expirationTimeMillis = 0;
if (control.getExpirationSecs() == -1)
{
expirationTimeMillis = Long.MAX_VALUE;
}
else if (control.getExpirationSecs() > 0)
{
expirationTimeMillis = System.currentTimeMillis() + control.getExpirationSecs() * 1000;
}
// Cache if we can
if (expirationTimeMillis > 0)
{
// Use validation token if any
String validationToken = null;
if (control.getValidationToken() != null)
{
validationToken = control.getValidationToken();
}
else if (cachedEntry != null)
{
validationToken = cachedEntry.validationToken;
}