Set expires header to given amount of hours in the future.
@param response Response
@param hours Hours to expire
549803
public static void setExpiresHours(@NotNull HttpServletResponse response, int hours) {
    Date expiresDate = DateUtils.addHours(new Date(), hours);
    setExpires(response, expiresDate);
  }
1305312
protected void setResponseHeaders(HttpServletResponse resp) {
		// Force resource caching as best as possible
		resp.setHeader(CACHE_CONTROL_HEADER, CACHE_CONTROL_VALUE);
		resp.setHeader(LAST_MODIFIED_HEADER, LAST_MODIFIED_VALUE);
		resp.setHeader(ETAG_HEADER, ETAG_VALUE);
		Calendar cal = Calendar.getInstance();
		cal.roll(Calendar.YEAR, 10);
		resp.setDateHeader(EXPIRES_HEADER, cal.getTimeInMillis());
	}
377008
public void update(HttpResponse response) {
		long time = System.currentTimeMillis();
		long networkTime = time - contextTsCurrent.get();
		contextMsNetwork.set(contextMsNetwork.get() + networkTime);
		contextTsCurrent.set(time);
		
		StringBuilder cookiesDump = new StringBuilder();
		for (Header h : response.getAllHeaders()) {
			if ("Set-Cookie".equalsIgnoreCase(h.getName())) {
				try {
					Map<String, Cookie> cookiez = getServerCookiesFrom(h);
					requestCookies.get().putAll(cookiez);
					responseCookies.get().putAll(cookiez);
					cookiesDump.append(h.toString()).append(";");
				} catch (MalformedCookieException e) {
					log.error("discarding malformed cookie", e);
				}
			}
		}

		if (verbose) log.info("    Time " + String.valueOf(time - contextTsStart.get()) + " (+" + networkTime + "n) <<< [" + contextUrl.get() + "] <<< " + contextRequest.get() + ". Set-Cookie to thread local: " + cookiesDump.toString());
	}
177257
public final void setCustomResponseHeaders (@Nullable final HttpHeaderMap aOther)
  {
    m_aResponseHeaderMap.removeAll ();
    if (aOther != null)
      m_aResponseHeaderMap.setAllHeaders (aOther);
  }
1069910
public static void setCookieValue(HttpServletResponse response, String key, String value)
	{
		setCookieValue(response, key, value, "/", -1);
	}
420851
public static Cache.Entry parseCacheHeaders(NetworkResponse response) {
        long now = System.currentTimeMillis();

        Headers headers = response.headers;

        long serverDate = 0;
        long lastModified = 0;
        long serverExpires = 0;
        long softExpire = 0;
        long finalExpire = 0;
        long maxAge = 0;
        long staleWhileRevalidate = 0;
        boolean hasCacheControl = false;
        boolean mustRevalidate = false;

        String serverEtag = null;
        String headerValue;
        List<String> headerValues;

        headerValue = headers.get("Date");
        if (headerValue != null) {
            serverDate = parseDateAsEpoch(headerValue);
        }

        //TODO check multiple cache and make stale if more than 1 value for given directive
        headerValues = headers.values("Cache-Control");
        if (headerValues != null && headerValues.size() > 0) {
            hasCacheControl = true;
            for (int i = 0; i < headerValues.size(); i++) {
                String[] tokens = headerValues.get(i).trim().split(",");
                for (int j = 0; j < tokens.length; j++) {
                    String token = tokens[j].trim();
                    if (token.equals("no-cache") || token.equals("no-store")) {
                        return null;
                    } else if (token.startsWith("max-age=")) {
                        try {
                            maxAge = Long.parseLong(token.substring(8));
                        } catch (Exception e) {
                        }
                    } else if (token.startsWith("stale-while-revalidate=")) {
                        try {
                            staleWhileRevalidate = Long.parseLong(token.substring(23));
                        } catch (Exception e) {
                        }
                    } else if (token.equals("must-revalidate") || token.equals("proxy-revalidate")) {

                        mustRevalidate = true;
                    }
                }
            }
        }

        headerValue = headers.get("Expires");
        if (headerValue != null) {
            serverExpires = parseDateAsEpoch(headerValue);
        }

        headerValue = headers.get("Last-Modified");
        if (headerValue != null) {
            lastModified = parseDateAsEpoch(headerValue);
        }

        serverEtag = headers.get("ETag");

        // Cache-Control takes precedence over an Expires header, even if both exist and Expires
        // is more restrictive.
        if (hasCacheControl) {
            softExpire = now + maxAge * 1000;
            finalExpire = mustRevalidate
                    ? softExpire
                    : softExpire + staleWhileRevalidate * 1000;
        } else if (serverDate > 0 && serverExpires >= serverDate) {
            // Default semantic for Expire header in HTTP specification is softExpire.
            softExpire = now + (serverExpires - serverDate);
            finalExpire = softExpire;
        }

        Cache.Entry entry = new Cache.Entry();
        entry.data = response.data;
        entry.etag = serverEtag;
        entry.softTtl = softExpire;
        entry.ttl = finalExpire;
        entry.serverDate = serverDate;
        entry.lastModified = lastModified;
        entry.responseHeaders = headers;

        return entry;
    }
99641
private void setHeaders(HttpServletResponse response) {
        setHeader(response, "Expires", Long.valueOf(System.currentTimeMillis() + cacheTimeoutMs).toString()); 
        setHeader(response, "Cache-Control", "public, must-revalidate, max-age=" + cacheTimeout); // HTTP 1.1.
        setHeader(response, "Pragma", "public"); 
    }
969261
public static function cacheHeaders($expires = '+1 hour')
    {
        if (!headers_sent()) {
            header('Cache-Control: private, max-age=3600');
            header('Pragma: public');
            header('Last-Modified: ' . date(DATE_RFC822, strtotime('-1 second')));
            header('Expires: ' . date(DATE_RFC822, strtotime($expires)));
        }
    }
297700
def update_headers(self, response):
        
        if 'expires' in response.headers and 'cache-control' in response.headers:
            self.msg = self.server_cache_headers
            return response.headers
        else:
            self.msg = self.default_cache_vars
            date = parsedate(response.headers['date'])
            expires = datetime(*date[:6]) + timedelta(0, self.expire_after)
            response.headers.update({'expires': formatdate(calendar.timegm(expires.timetuple())),
                                'cache-control': 'public'})
            return response.headers
577550
public function setCacheHeaders($expirationTimeInSeconds = 300) {
        $expirationString = strtotime("+{$expirationTimeInSeconds} seconds");
        $gmtDate = gmdate(DATE_RFC1123, $expirationString);

        $this->getResponse()
            ->setHeader('Cache-Control', 'public', true)
            ->setHeader('Pragma', 'cache', true)
            ->setHeader('Expires', $gmtDate, true);
    }
746042
private function _setResponseHeaders()
    {
        $this->_response->setHeader("Expires", "Mon, 26 Jul 1997 05:00:00 GMT", true)
                        ->setHeader("Last-Modified", gmdate("D, d M Y H:i:s") . " GMT", true)
                        ->setHeader("Cache-Control", "no-store, no-cache, must-revalidate", true)
                        ->setHeader("Cache-Control", "post-check=0, pre-check=0", false)
                        ->setHeader("Pragma", "no-cache", true)
                        ->sendHeaders();
    }
984038
protected void writeHeaders(HttpServletResponse response, Resource resource, long count) throws IOException
    {
        ResourceCache.ResourceMetaData metaData = _httpContext.getResourceMetaData(resource);

        response.setContentType(metaData.getMimeType());
        if (count != -1)
        {
            if (count == resource.length() && response instanceof ServletHttpResponse )
                response.setHeader(HttpFields.__ContentLength, metaData.getLength());
            else
                response.setContentLength((int) count);
        }

        response.setHeader(HttpFields.__LastModified, metaData.getLastModified());

        if (_acceptRanges)
            response.setHeader(HttpFields.__AcceptRanges, "bytes");
    }
436534
public static void setExpires(@NotNull HttpServletResponse response, @Nullable Date date) {
    if (date == null) {
      response.setHeader(HEADER_EXPIRES, "-1");
    }
    else {
      response.setHeader(HEADER_EXPIRES, formatDate(date));
    }
  }
190538
function(headers) {
    var cookies = headers['set-cookie']
    if (cookies) {
      cookies.forEach(function(c) {
        var cookiesParams = c.split(';')
        var cookiePair = cookiesParams.shift().split('=')
        var options = {}
        cookiesParams.forEach(function(param) {
          param = param.trim()
          if (param.toLowerCase().indexOf('expires') == 0) {
            var date = param.split('=')[1].trim()
            options.expires = new Date(date)
          }
        })
        this.set(cookiePair[0].trim(), cookiePair[1].trim(), options)
      }.bind(this))
    }
  }
728681
public void writeHeaders(HttpResponse response,Resource resource, long count)
        throws IOException
    {
        ResourceCache.ResourceMetaData metaData =
            (ResourceCache.ResourceMetaData)resource.getAssociate();

        response.setContentType(metaData.getMimeType());
        if (count != -1)
        {
            if (count==resource.length())
                response.setField(HttpFields.__ContentLength,metaData.getLength());
            else
                response.setContentLength((int)count);
        }

        response.setField(HttpFields.__LastModified,metaData.getLastModified());
        
        if (_acceptRanges && response.getHttpRequest().getDotVersion()>0)
            response.setField(HttpFields.__AcceptRanges,"bytes");
    }
738153
public void doHead(String url, HttpResponse response, Map<String, Object> headers) {
        response.setRequest(url);
        httpClient.head(url, response, headers);
    }
314399
private static void setDateHeader(final FullHttpResponse response) {
    final SimpleDateFormat dateFormatter = new SimpleDateFormat(HTTP_DATE_FORMAT, Locale.US);
    dateFormatter.setTimeZone(TimeZone.getTimeZone(HTTP_DATE_GMT_TIMEZONE));

    final Calendar time = new GregorianCalendar();
    response.headers().set(DATE, dateFormatter.format(time.getTime()));
  }