in extscript-core-root/extscript-core/src/main/java/org/apache/myfaces/extensions/scripting/jsf/resources/deprecated/ResourceImpl.java [267:316]
public boolean userAgentNeedsUpdate(FacesContext context) {
// RFC2616 says related to If-Modified-Since header the following:
//
// "... The If-Modified-Since request-header field is used with a method to
// make it conditional: if the requested variant has not been modified since
// the time specified in this field, an entity will not be returned from
// the server; instead, a 304 (not modified) response will be returned
// without any message-body..."
//
// This method is called from ResourceHandlerImpl.handleResourceRequest and if
// returns false send a 304 Not Modified response.
String ifModifiedSinceString = context.getExternalContext().getRequestHeaderMap().get("If-Modified-Since");
if (ifModifiedSinceString == null) {
return true;
}
Long ifModifiedSince = ResourceLoaderUtils.parseDateHeader(ifModifiedSinceString);
if (ifModifiedSince == null) {
return true;
}
Long lastModified;
try {
lastModified = ResourceLoaderUtils.getResourceLastModified(this.getURL());
} catch (IOException exception) {
lastModified = -1L;
}
if (lastModified >= 0) {
if (this.couldResourceContainValueExpressions() &&
lastModified < _resourceHandlerSupport.getStartupTime()) {
lastModified = _resourceHandlerSupport.getStartupTime();
}
// If the lastModified date is lower or equal than ifModifiedSince,
// the agent does not need to update.
// Note the lastModified time is set at milisecond precision, but when
// the date is parsed and sent on ifModifiedSince, the exceding miliseconds
// are trimmed. So, we have to compare trimming this from the calculated
// lastModified time.
if ((lastModified - (lastModified % 1000)) <= ifModifiedSince) {
return false;
}
}
return true;
}