Returns true if none of the Vary headers have changed between {@code cachedRequest} and {@code
newRequest}.
515981
public static boolean varyMatches(
      Response cachedResponse, Headers cachedRequest, Request newRequest) {
    for (String field : varyFields(cachedResponse)) {
      if (!Objects.equals(cachedRequest.values(field), newRequest.headers(field))) return false;
    }
    return true;
  }
265374
private boolean headerEq(HttpRequestBase request, String headerName, String headerValue) {
        Header[] headers = request.getAllHeaders();
        if (headers != null) {
            for(Header h : headers) {
                if (headerName.equalsIgnoreCase(h.getName()) && headerValue.equalsIgnoreCase(h.getValue())) {
                    return true;
                }
            }
        }
        return false;
    }
1317090
private boolean isCacheValid()
  {
    long now = CurrentTime.currentTime();

    if ((now - _lastTime < 100) && ! CurrentTime.isTest())
      return true;

    long oldLastModified = _lastModified;
    long oldLength = _length;
    
    long newLastModified = getBacking().getLastModified();
    long newLength = getBacking().length();
    
    _lastTime = now;

    if (newLastModified == oldLastModified && newLength == oldLength) {
      _lastTime = now;
      return true;
    }
    else {
      _changeSequence.incrementAndGet();
      
      // If the file has changed, close the old file
      clearCache();
      
      _zipEntryCache.clear();
      
      _lastModified = newLastModified;
      _length = newLength;
      
      _lastTime = now;

      return false;
    }
  }
984626
def cached_request(self, request):
        
        cache_url = self.cache_url(request.url)
        logger.debug('Looking up "%s" in the cache', cache_url)
        cc = self.parse_cache_control(request.headers)

        # Bail out if the request insists on fresh data
        if "no-cache" in cc:
            logger.debug('Request header has "no-cache", cache bypassed')
            return False

        if "max-age" in cc and cc["max-age"] == 0:
            logger.debug('Request header has "max_age" as 0, cache bypassed')
            return False

        # Request allows serving from the cache, let's see if we find something
        cache_data = self.cache.get(cache_url)
        if cache_data is None:
            logger.debug("No cache entry available")
            return False

        # Check whether it can be deserialized
        resp = self.serializer.loads(request, cache_data)
        if not resp:
            logger.warning("Cache entry deserialization failed, entry ignored")
            return False

        # If we have a cached 301, return it immediately. We don't
        # need to test our response for other headers b/c it is
        # intrinsically "cacheable" as it is Permanent.
        # See:
        #   https://tools.ietf.org/html/rfc7231#section-6.4.2
        #
        # Client can try to refresh the value by repeating the request
        # with cache busting headers as usual (ie no-cache).
        if resp.status == 301:
            msg = (
                'Returning cached "301 Moved Permanently" response '
                "(ignoring date and etag information)"
            )
            logger.debug(msg)
            return resp

        headers = CaseInsensitiveDict(resp.headers)
        if not headers or "date" not in headers:
            if "etag" not in headers:
                # Without date or etag, the cached response can never be used
                # and should be deleted.
                logger.debug("Purging cached response: no date or etag")
                self.cache.delete(cache_url)
            logger.debug("Ignoring cached response: no date")
            return False

        now = time.time()
        date = calendar.timegm(parsedate_tz(headers["date"]))
        current_age = max(0, now - date)
        logger.debug("Current age based on date: %i", current_age)

        # TODO: There is an assumption that the result will be a
        #       urllib3 response object. This may not be best since we
        #       could probably avoid instantiating or constructing the
        #       response until we know we need it.
        resp_cc = self.parse_cache_control(headers)

        # determine freshness
        freshness_lifetime = 0

        # Check the max-age pragma in the cache control header
        if "max-age" in resp_cc:
            freshness_lifetime = resp_cc["max-age"]
            logger.debug("Freshness lifetime from max-age: %i", freshness_lifetime)

        # If there isn't a max-age, check for an expires header
        elif "expires" in headers:
            expires = parsedate_tz(headers["expires"])
            if expires is not None:
                expire_time = calendar.timegm(expires) - date
                freshness_lifetime = max(0, expire_time)
                logger.debug("Freshness lifetime from expires: %i", freshness_lifetime)

        # Determine if we are setting freshness limit in the
        # request. Note, this overrides what was in the response.
        if "max-age" in cc:
            freshness_lifetime = cc["max-age"]
            logger.debug(
                "Freshness lifetime from request max-age: %i", freshness_lifetime
            )

        if "min-fresh" in cc:
            min_fresh = cc["min-fresh"]
            # adjust our current age by our min fresh
            current_age += min_fresh
            logger.debug("Adjusted current age from min-fresh: %i", current_age)

        # Return entry if it is fresh enough
        if freshness_lifetime > current_age:
            logger.debug('The response is "fresh", returning cached response')
            logger.debug("%i > %i", freshness_lifetime, current_age)
            return resp

        # we're not fresh. If we don't have an Etag, clear it out
        if "etag" not in headers:
            logger.debug('The cached response is "stale" with no etag, purging')
            self.cache.delete(cache_url)

        # return the original handler
        return False
1018017
public static void setNoCache(HttpServletRequest request,
								  HttpServletResponse response)
	{
		//get rid of unwanted whitespace
		String protocol = request.getProtocol().trim();

//		if ("HTTP/1.0".equals(protocol))
		{
			response.setHeader("Pragma", "no-cache");
		}
//		else if ("HTTP/1.1".equals(protocol))
		{
			response.setHeader("Cache-Control", "no-cache, max-age=0, revalidate");//no-store only disables archiving
		}

		//get browser type
//		String userAgent = request.getHeader("User-Agent");

//		if ((userAgent != null) && (userAgent.indexOf("MSIE") != -1))
		{
			//Internet Explorer:
			//date and timestamp will be set to jan 1st 1970, so no caching is performed.
//			response.setDateHeader("Expires", 0);
		}
		long now = System.currentTimeMillis();
		response.setDateHeader("Date", now);
		response.setDateHeader("Expires", now);
		response.setDateHeader("Last-Modified", now);


	}
718803
public static boolean isEditableRequest(ServletRequest req) {

        boolean result = false;
        if (CmsHistoryResourceHandler.isHistoryRequest(req) || CmsJspTagEnableAde.isDirectEditDisabled(req)) {
            // don't display direct edit buttons on an historical resource
            result = false;
        } else {
            CmsFlexController controller = CmsFlexController.getController(req);
            CmsObject cms = controller.getCmsObject();
            result = !cms.getRequestContext().getCurrentProject().isOnlineProject()
                && !CmsResource.isTemporaryFileName(cms.getRequestContext().getUri());

        }
        return result;
    }
252730
public boolean shouldNotCache(String requestUri) {
		String uri = requestUri.toLowerCase();
		return checkContains(uri, noCacheIdentifiers) || checkSuffixes(uri, noCacheSuffixes);
	}
157553
public void addRequest(final CachedSpiceRequest<?> request, final Set<RequestListener<?>> listRequestListener) {
        if (isStopped) {
            Ln.d("Dropping request : " + request + " as processor is stopped.");
            return;
        }

        Ln.d("Adding request to queue " + hashCode() + ": " + request + " size is " + mapRequestToRequestListener.size());

        if (request.isCancelled()) {
            synchronized (mapRequestToRequestListener) {
                for (final CachedSpiceRequest<?> cachedSpiceRequest : mapRequestToRequestListener.keySet()) {
                    if (request.equals(cachedSpiceRequest)) {
                        cachedSpiceRequest.cancel();
                        requestProgressManager.notifyListenersOfRequestCancellation(request);
                        return;
                    }
                }
            }
        }

        boolean aggregated = false;
        Set<RequestListener<?>> listRequestListenerForThisRequest;

        synchronized (mapRequestToRequestListener) {
            listRequestListenerForThisRequest = mapRequestToRequestListener.get(request);

            if (listRequestListenerForThisRequest == null) {
                if (request.isProcessable()) {
                    Ln.d("Adding entry for type %s and cacheKey %s.", request.getResultType(), request.getRequestCacheKey());
                    listRequestListenerForThisRequest = Collections.synchronizedSet(new HashSet<RequestListener<?>>());
                    this.mapRequestToRequestListener.put(request, listRequestListenerForThisRequest);
                }
            } else {
                Ln.d("Request for type %s and cacheKey %s already exists.", request.getResultType(), request.getRequestCacheKey());
                aggregated = true;
            }
        }

        if (listRequestListener != null && listRequestListenerForThisRequest != null) {
            listRequestListenerForThisRequest.addAll(listRequestListener);
        }

        if (aggregated) {
            requestProgressManager.notifyListenersOfRequestAggregated(request, listRequestListener);
            return;
        }

        if (request.isProcessable()) {
            requestProgressManager.notifyListenersOfRequestAdded(request, listRequestListener);
        } else {
            if (listRequestListenerForThisRequest == null) {
                requestProgressManager.notifyListenersOfRequestNotFound(request, listRequestListener);
            }
            requestProgressManager.notifyOfRequestProcessed(request, listRequestListener);
            // we have to return if request is not processable.
            // fix bug https://github.com/octo-online/robospice/issues/215
            return;
        }

        final RequestCancellationListener requestCancellationListener = new RequestCancellationListener() {

            @Override
            public void onRequestCancelled() {
                requestProgressManager.notifyListenersOfRequestCancellation(request);
                mapRequestToRequestListener.remove(request);
            }
        };
        request.setRequestCancellationListener(requestCancellationListener);

        if (request.isCancelled()) {
            requestProgressManager.notifyListenersOfRequestCancellation(request);
            mapRequestToRequestListener.remove(request);
            return;
        } else {
            requestRunner.executeRequest(request);
        }
    }
562288
public synchronized boolean setPools(Collection<HostConnectionPool<CL>> newPools) {
        Set<HostConnectionPool<CL>> toRemove = Sets.newHashSet(this.pools);
        
        // Add new pools not previously seen
        boolean didChange = false;
        for (HostConnectionPool<CL> pool : newPools) {
            if (this.pools.add(pool))   
                didChange = true;
            toRemove.remove(pool);
        }
    
        // Remove pools for hosts that no longer exist
        for (HostConnectionPool<CL> pool : toRemove) {
            if (this.pools.remove(pool))
                didChange = true;
        }
    
        if (didChange)
            refresh();
        return didChange;
    }
771853
private void requestCacheUpdate() {
        log.debug("Cache update requested");
        if (updateRequested) {
            log.debug("Cache update, redundant request ignored.");
            return;
        }

        updateRequested = true;

        if (!updating) {
            updateCache();
        }
    }
334770
function isAccessedVarChanged(cacheData) {
  for (let key in cacheData.env) {
    if (cacheData.env[key] !== process.env[key]) {
      return true;
    }
  }

  return false;
}
977426
@RequestMapping(value = "changelog/diff", method = RequestMethod.GET)
    public ResponseEntity<String> diff(FileDiffChangeLogRequest request) {
        // Null proof
        FileDiffChangeLogRequest nonNullRequest = request != null ? request : new FileDiffChangeLogRequest();
        // Gets the change log
        GitChangeLog changeLog = gitService.changeLog(nonNullRequest);
        // Diff export
        String diff = gitService.diff(
                changeLog,
                nonNullRequest.getPatterns()
        );
        // Content type
        HttpHeaders responseHeaders = new HttpHeaders();
        responseHeaders.set("Content-Type", "text/plain");
        // Body and headers
        return new ResponseEntity<>(diff, responseHeaders, HttpStatus.OK);
    }
963727
private boolean _isRedirectTrueOnPreviousRequest(FacesContext facesContext)
    {
        ExternalContext externalContext = facesContext.getExternalContext();
        Map<String, Object> requestMap = externalContext.getRequestMap();
        Boolean redirect = (Boolean) requestMap.get(FLASH_PREVIOUS_REQUEST_REDIRECT);
        
        return Boolean.TRUE.equals(redirect);
    }
540890
private boolean hasParametersChanged()
	{
		boolean changed = false;
		for (ICachedData<?> data : parameters.values())
		{
			data.update();
			if (data.hasChanged())
				changed |= true; //can't return early, we need to call update on each data
		}
		return changed;
	}
924108
function Request_isHeaderCacheUnModified() {

        var etagMatches = true,
            notModified = true,
            modifiedSince = this.getRequestHeader('if-modified-since'),
            noneMatch = this.getRequestHeader('if-none-match'),
            cc = this.getRequestHeader('cache-control'),
            lastModified = this.getHeader('last-modified'),
            etag = this.getHeader('etag');


        // unconditional request
        if (!modifiedSince && !noneMatch) {
            return false;
            // check for no-cache cache request directive
        } else if (cc && cc.indexOf('no-cache') !== -1) {
            return false;
        }

        // parse if-none-match
        if (noneMatch) {
            noneMatch = noneMatch.split(/ *, */);
        }
        // if-none-match
        if (noneMatch) {
            etagMatches = ~noneMatch.indexOf(etag) || '*' == noneMatch[0];
        }
        // if-modified-since
        if (modifiedSince) {
            modifiedSince = Date.parse(modifiedSince);
            lastModified = Date.parse(lastModified);
            notModified = lastModified <= modifiedSince;
        }

        return !!(etagMatches && notModified);
    }
381378
public final <R extends Request<T>> R setShouldCache(boolean shouldCache) {
        checkIfActive();
        this.shouldCache = shouldCache;
        return (R) this;
    }
151698
public static boolean isCachedContentRequest(final Request request) {

		// Get target id on request
		String targetId = request.getParameter(Environment.TARGET_ID);
		if (targetId == null) {
			return false;
		}

		// Get target
		ComponentWithContext targetWithContext = WebUtilities.getComponentById(targetId, true);
		if (targetWithContext == null) {
			return false;
		}

		// Check for caching key
		WComponent target = targetWithContext.getComponent();
		UIContextHolder.pushContext(targetWithContext.getContext());

		try {
			// TODO Look at implementing CacheableTarget interface
			String key = null;
			if (target instanceof WContent) {
				key = ((WContent) target).getCacheKey();
			} else if (target instanceof WImage) {
				key = ((WImage) target).getCacheKey();
			} else if (target instanceof WVideo) {
				key = ((WVideo) target).getCacheKey();
			} else if (target instanceof WAudio) {
				key = ((WAudio) target).getCacheKey();
			}
			return !Util.empty(key);
		} finally {
			UIContextHolder.popContext();
		}
	}