/** * <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); }
/** * <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); }
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()); }
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()); }