/** * @param response {@code WebResponse} * @return value of 's-maxage' directive and 0 if it is absent */ public static long sMaxage(final WebResponse response) { if (containsValue(response, CACHE_CONTROL_S_MAXAGE)) { return directiveValue(response, S_MAXAGE_HEADER_PATTERN); } return 0; }
final long now = getCurrentTimestamp(); long freshnessLifetime = 0; if (!HeaderUtils.containsPrivate(response) && HeaderUtils.containsSMaxage(response)) { freshnessLifetime = HeaderUtils.sMaxage(response); else if (HeaderUtils.containsMaxAge(response)) { freshnessLifetime = HeaderUtils.maxAge(response);
/** * @param response {@code WebResponse} * @return if 'Cache-Control' header is present and contains 'no-store' value */ public static boolean containsNoStore(final WebResponse response) { return containsValue(response, CACHE_CONTROL_NO_STORE); }
/** * <p>Perform prior validation for 'no-store' directive in Cache-Control header.</p> * * <p>Tries to guess if the content is dynamic or not.</p> * * <p>"Since origin servers do not always provide explicit expiration times, HTTP caches typically * assign heuristic expiration times, employing algorithms that use other header values (such as the * <tt>Last-Modified</tt> time) to estimate a plausible expiration time".</p> * * <p>The current implementation considers as dynamic content everything except responses with a * <tt>Last-Modified</tt> header with a date older than 10 minutes or with an <tt>Expires</tt> header * specifying expiration in more than 10 minutes.</p> * * @see <a href="https://tools.ietf.org/html/rfc7234">RFC 7234</a> * @see <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html">RFC 2616</a> * @param response the response to examine * @return {@code true} if the response should be considered as cacheable */ protected boolean isCacheableContent(final WebResponse response) { if (HeaderUtils.containsNoStore(response)) { return false; } final Date lastModified = parseDateHeader(response, HttpHeader.LAST_MODIFIED); final Date expires = parseDateHeader(response, HttpHeader.EXPIRES); final long now = getCurrentTimestamp(); return expires != null && (expires.getTime() - now > DELAY) || (expires == null && lastModified != null && now - lastModified.getTime() > DELAY); }
final long now = getCurrentTimestamp(); long freshnessLifetime = 0; if (!HeaderUtils.containsPrivate(response) && HeaderUtils.containsSMaxage(response)) { freshnessLifetime = HeaderUtils.sMaxage(response); else if (HeaderUtils.containsMaxAge(response)) { freshnessLifetime = HeaderUtils.maxAge(response);
/** * @param response {@code WebResponse} * @return if 'Cache-Control' header is present and contains 'private' value */ public static boolean containsPrivate(final WebResponse response) { return containsValue(response, CACHE_CONTROL_PRIVATE); }
/** * <p>Perform prior validation for 'no-store' directive in Cache-Control header.</p> * * <p>Tries to guess if the content is dynamic or not.</p> * * <p>"Since origin servers do not always provide explicit expiration times, HTTP caches typically * assign heuristic expiration times, employing algorithms that use other header values (such as the * <tt>Last-Modified</tt> time) to estimate a plausible expiration time".</p> * * <p>The current implementation considers as dynamic content everything except responses with a * <tt>Last-Modified</tt> header with a date older than 10 minutes or with an <tt>Expires</tt> header * specifying expiration in more than 10 minutes.</p> * * @see <a href="https://tools.ietf.org/html/rfc7234">RFC 7234</a> * @see <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html">RFC 2616</a> * @param response the response to examine * @return {@code true} if the response should be considered as cacheable */ protected boolean isCacheableContent(final WebResponse response) { if (HeaderUtils.containsNoStore(response)) { return false; } final Date lastModified = parseDateHeader(response, HttpHeader.LAST_MODIFIED); final Date expires = parseDateHeader(response, HttpHeader.EXPIRES); final long now = getCurrentTimestamp(); return expires != null && (expires.getTime() - now > DELAY) || (expires == null && lastModified != null && now - lastModified.getTime() > DELAY); }
/** * @param response {@code WebResponse} * @return value of 'max-age' directive and 0 if it is absent */ public static long maxAge(final WebResponse response) { if (containsValue(response, CACHE_CONTROL_MAX_AGE)) { return directiveValue(response, MAX_AGE_HEADER_PATTERN); } return 0; }
/** * @param response {@code WebResponse} * @return if 'Cache-Control' header is present and contains 'max-age' value */ public static boolean containsMaxAge(final WebResponse response) { return containsValue(response, CACHE_CONTROL_MAX_AGE); }
private HistoryEntry(final Page page) { // verify cache-control header values before storing if (HeaderUtils.containsNoStore(page.getWebResponse())) { page_ = null; } else { page_ = new SoftReference<>(page); } final WebRequest request = page.getWebResponse().getWebRequest(); webRequest_ = new WebRequest(request.getUrl(), request.getHttpMethod()); webRequest_.setRequestParameters(request.getRequestParameters()); }
/** * @param response {@code WebResponse} * @return value of 's-maxage' directive and 0 if it is absent */ public static long sMaxage(final WebResponse response) { if (containsValue(response, CACHE_CONTROL_S_MAXAGE)) { return directiveValue(response, S_MAXAGE_HEADER_PATTERN); } return 0; }
/** * @param response {@code WebResponse} * @return if 'Cache-Control' header is present and contains 'private' value */ public static boolean containsPrivate(final WebResponse response) { return containsValue(response, CACHE_CONTROL_PRIVATE); }
private HistoryEntry(final Page page) { // verify cache-control header values before storing if (HeaderUtils.containsNoStore(page.getWebResponse())) { page_ = null; } else { page_ = new SoftReference<>(page); } final WebRequest request = page.getWebResponse().getWebRequest(); webRequest_ = new WebRequest(request.getUrl(), request.getHttpMethod()); webRequest_.setRequestParameters(request.getRequestParameters()); }
/** * @param response {@code WebResponse} * @return value of 'max-age' directive and 0 if it is absent */ public static long maxAge(final WebResponse response) { if (containsValue(response, CACHE_CONTROL_MAX_AGE)) { return directiveValue(response, MAX_AGE_HEADER_PATTERN); } return 0; }
/** * @param response {@code WebResponse} * @return if 'Cache-Control' header is present and contains 'public' value */ public static boolean containsPublic(final WebResponse response) { return containsValue(response, CACHE_CONTROL_PUBLIC); }
/** * @param response {@code WebResponse} * @return if 'Cache-Control' header is present and contains 's-maxage' value */ public static boolean containsSMaxage(final WebResponse response) { return containsValue(response, CACHE_CONTROL_S_MAXAGE); }
/** * @param response {@code WebResponse} * @return if 'Cache-Control' header is present and contains 'no-store' value */ public static boolean containsNoStore(final WebResponse response) { return containsValue(response, CACHE_CONTROL_NO_STORE); }
/** * @param response {@code WebResponse} * @return if 'Cache-Control' header is present and contains 'no-cache' value@return */ public static boolean containsNoCache(final WebResponse response) { return containsValue(response, CACHE_CONTROL_NO_CACHE); }
/** * @param response {@code WebResponse} * @return if 'Cache-Control' header is present and contains 'max-age' value */ public static boolean containsMaxAge(final WebResponse response) { return containsValue(response, CACHE_CONTROL_MAX_AGE); }
/** * @param response {@code WebResponse} * @return if 'Cache-Control' header is present and contains 'no-cache' value@return */ public static boolean containsNoCache(final WebResponse response) { return containsValue(response, CACHE_CONTROL_NO_CACHE); }