List of usage examples for org.apache.http.client.cache HeaderConstants PRAGMA
String PRAGMA
To view the source code for org.apache.http.client.cache HeaderConstants PRAGMA.
Click Source Link
From source file:org.apache.http.impl.client.cache.CacheableRequestPolicy.java
/** * Determines if an HttpRequest can be served from the cache. * * @param request/*from w ww .j a va2s. c o m*/ * an HttpRequest * @return boolean Is it possible to serve this request from cache */ public boolean isServableFromCache(HttpRequest request) { String method = request.getRequestLine().getMethod(); ProtocolVersion pv = request.getRequestLine().getProtocolVersion(); if (HttpVersion.HTTP_1_1.compareToVersion(pv) != 0) { log.debug("Request was not serveable from cache"); return false; } if (!method.equals(HeaderConstants.GET_METHOD)) { log.debug("Request was not serveable from cache"); return false; } if (request.getHeaders(HeaderConstants.PRAGMA).length > 0) { log.debug("Request was not serveable from cache"); return false; } Header[] cacheControlHeaders = request.getHeaders(HeaderConstants.CACHE_CONTROL); for (Header cacheControl : cacheControlHeaders) { for (HeaderElement cacheControlElement : cacheControl.getElements()) { if (HeaderConstants.CACHE_CONTROL_NO_STORE.equalsIgnoreCase(cacheControlElement.getName())) { log.debug("Request was not serveable from Cache"); return false; } if (HeaderConstants.CACHE_CONTROL_NO_CACHE.equalsIgnoreCase(cacheControlElement.getName())) { log.debug("Request was not serveable from cache"); return false; } } } log.debug("Request was serveable from cache"); return true; }