public String getEntityTag(FacesContext context) { int contentLength = getContentLength(context); Date lastModified = getLastModified(context); if ((contentLength < 0) || (lastModified == null)) { return null; } return ResourceUtils.formatWeakTag(contentLength + "-" + lastModified.getTime()); }
protected boolean isMatchesEntityTag(FacesContext context, String matchHeaderValue) { String resourceEntityTag = getEntityTag(context); if (resourceEntityTag == null) { return false; } return ResourceUtils.matchTag(resourceEntityTag, matchHeaderValue); }
@Override public Map<String, String> getResponseHeaders() { Map<String, String> headers = super.getResponseHeaders(); Map<String, String> userHeaders = getWrappedResourceResponseHeaders(); if (userHeaders != null) { headers.putAll(userHeaders); } return headers; }
protected boolean isMatchesLastModified(FacesContext context, String modifiedCondition) { Date lastModified = getLastModified(context); if (lastModified == null) { return false; } return isUserCopyActual(lastModified, ResourceUtils.parseHttpDate(modifiedCondition)); }
@Override protected void addCacheControlResponseHeaders(FacesContext facesContext, Map<String, String> headers) { if (isCacheable(facesContext)) { long currentTime = getCurrentTime(); String formattedExpireDate; long maxAge = getTimeToLive(facesContext); Date expired = getExpires(facesContext); String entityTag = getEntityTag(facesContext); addNoCacheResponseHeaders(facesContext, headers);
@Override public boolean userAgentNeedsUpdate(FacesContext context) { if (!isCacheable(context)) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("User agent cache check: resource is not cacheable"); if ((matchHeaderValue != null) && !isMatchesEntityTag(context, matchHeaderValue)) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("User agent cache check: entity tags don't match"); if ((modifiedCondition != null) && !isMatchesLastModified(context, modifiedCondition)) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("User agent cache check: resource was modified since the last request");
@Deprecated protected Boolean isMatchesEntityTag(FacesContext context) { ExternalContext externalContext = context.getExternalContext(); Map<String, String> requestHeaderMap = externalContext.getRequestHeaderMap(); String matchHeaderValue = requestHeaderMap.get("If-None-Match"); if (matchHeaderValue == null) { return null; } return isMatchesEntityTag(context, matchHeaderValue); }