[OmniFaces utilities] The
getDefaultResourceMaxAge()
method returns the default resource maximum age in milliseconds.Method:
See also: Faces#getInitParameter()
Usage:import org.omnifaces.util.Hacks;
...
// e.g. 604800000
milliseconds
long maxAge
= Hacks.getDefaultResourceMaxAge();
OmniFaces uses this method to set the Expires response header in org.omnifaces.resourcehandler.DynamicResource:
OmniFaces uses this method to set the Expires response header in org.omnifaces.resourcehandler.DynamicResource:
@Override
public
Map<String, String> getResponseHeaders() {
Map<String, String> responseHeaders =
new HashMap<>(RESPONSE_HEADERS_SIZE);
responseHeaders.put("Last-Modified",
formatRFC1123(new Date(getLastModified())));
responseHeaders.put("Expires",
formatRFC1123(new Date(System.currentTimeMillis() +
Hacks.getDefaultResourceMaxAge())));
responseHeaders.put("Etag",
String.format("W/\"%d-%d\"", getResourceName().hashCode(),
getLastModified()));
responseHeaders.put("Pragma",
""); // Explicitly set empty pragma to prevent some containers from
setting it.
return responseHeaders;
}
Niciun comentariu :
Trimiteți un comentariu