Appends `Cache-Control`, `Expires` and `Pragma` (only if needed) headers.

@param {!Object} headers
@param {!number} cacheTimeInSeconds=0   Pass zero or less to disable cache.
333746
function appendCacheHeaders (headers, cacheTimeInSeconds) {
	headers['Cache-Control'] = (cacheTimeInSeconds > 1 ? 'private, max-age=' + cacheTimeInSeconds : 'no-cache, no-store, must-revalidate');
	headers.Expires = (cacheTimeInSeconds > 1 ? (new Date(Date.now() + (cacheTimeInSeconds * 1000))).toUTCString() : '0');

	if (cacheTimeInSeconds < 1) {
		headers.Pragma = 'no-cache';
	}

	return headers;
}
249457
protected void addNoCacheHeaders(HttpServletResponse response) {
		String cacheControlValue = response.getHeader(WebConstants.HEADER_CACHE_CONTROL);

		if (cacheControlValue != null && !cacheControlValue.isEmpty()) {
			cacheControlValue = cacheControlValue + ", " + WebConstants.CACHE_CONTROL_NO_STORE;
		} else {
			cacheControlValue = WebConstants.CACHE_CONTROL_NO_STORE;
		}

		response.setHeader(WebConstants.HEADER_CACHE_CONTROL, cacheControlValue);
		response.setHeader(WebConstants.HEADER_PRAGMA, WebConstants.PRAGMA_NO_CACHE);
	}
754555
public final B setHeaders(Headers<AsciiString, String, ?> headers) {
        requireNonNull(headers, "headers");
        if (!headers.isEmpty()) {
            getOrCreateHeaders().setAll(headers);
        }
        return self();
    }
275520
private void configureCaching(HttpServletResponse response, int seconds) {
		// HTTP 1.0 header
		response.setDateHeader(HTTP_EXPIRES_HEADER, System.currentTimeMillis() + seconds * 1000L);
		if (seconds > 0) {
			// HTTP 1.1 header
			response.setHeader(HTTP_CACHE_CONTROL_HEADER, "max-age=" + seconds);
		} else {
			// HTTP 1.1 header
			response.setHeader(HTTP_CACHE_CONTROL_HEADER, "no-cache");

		}
	}
785367
protected void putToCache(String cacheName, String key, Object value,
            long expireAfterWriteSeconds, long expireAfterAccessSeconds) {
        try {
            ICache cache = getCache(cacheName);
            if (value != null && cache != null) {
                cache.set(key, value, expireAfterWriteSeconds, expireAfterAccessSeconds);
            }
        } catch (CacheException e) {
            LOGGER.warn(e.getMessage(), e);
        }
    }
308315
private void addResponseHeaderParameters(InternalRequest request, ResponseHeaderOverrides responseHeaders) {
        if (responseHeaders != null) {
            if (responseHeaders.getCacheControl() != null) {
                request.addParameter(ResponseHeaderOverrides.RESPONSE_HEADER_CACHE_CONTROL,
                        responseHeaders.getCacheControl());
            }
            if (responseHeaders.getContentDisposition() != null) {
                request.addParameter(ResponseHeaderOverrides.RESPONSE_HEADER_CONTENT_DISPOSITION,
                        responseHeaders.getContentDisposition());
            }
            if (responseHeaders.getContentEncoding() != null) {
                request.addParameter(ResponseHeaderOverrides.RESPONSE_HEADER_CONTENT_ENCODING,
                        responseHeaders.getContentEncoding());
            }
            if (responseHeaders.getContentLanguage() != null) {
                request.addParameter(ResponseHeaderOverrides.RESPONSE_HEADER_CONTENT_LANGUAGE,
                        responseHeaders.getContentLanguage());
            }
            if (responseHeaders.getContentType() != null) {
                request.addParameter(ResponseHeaderOverrides.RESPONSE_HEADER_CONTENT_TYPE,
                        responseHeaders.getContentType());
            }
            if (responseHeaders.getExpires() != null) {
                request.addParameter(ResponseHeaderOverrides.RESPONSE_HEADER_EXPIRES, responseHeaders.getExpires());
            }
        }
    }
1227871
public function setExpires(string $expires)
    {
        if (empty($expires)) {
            Throw new HeaderException('Empty expires is not allowed.');
        }

        $this->expires = $expires;
    }
1345588
function expire($secs=0) {
		if (!$this->hive['CLI'] && !headers_sent()) {
			$secs=(int)$secs;
			if ($this->hive['PACKAGE'])
				header('X-Powered-By: '.$this->hive['PACKAGE']);
			if ($this->hive['XFRAME'])
				header('X-Frame-Options: '.$this->hive['XFRAME']);
			header('X-XSS-Protection: 1; mode=block');
			header('X-Content-Type-Options: nosniff');
			if ($this->hive['VERB']=='GET' && $secs) {
				$time=microtime(TRUE);
				header_remove('Pragma');
				header('Cache-Control: max-age='.$secs);
				header('Expires: '.gmdate('r',$time+$secs));
				header('Last-Modified: '.gmdate('r'));
			}
			else {
				header('Pragma: no-cache');
				header('Cache-Control: no-cache, no-store, must-revalidate');
				header('Expires: '.gmdate('r',0));
			}
		}
	}
1133227
public function noCache()
    {
        $header = new Expires('Mon, 26 Jul 1997 05:00:00 GMT');
        $this->addHeader($header);

        $header = new CacheControl('no-cache');
        $this->addHeader($header);

        $header = new Pragma('no-cache');
        $this->addHeader($header);
    }
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))
    }
  }
1358049
public function setNotCachingHeaders()
    {
        ResponseHeaders::add(ResponseHeaders::HEADER_CACHE_CONTROL, ResponseHeaders::HEADER_CACHE_CONTROL_CONTENT_NO_STORE_NO_CACHE_MUST_REVALIDATE_MAX_AGE_0);
        ResponseHeaders::add(ResponseHeaders::HEADER_PRAGMA, ResponseHeaders::HEADER_PRAGMA_CONTENT_NO_CACHE);
    }
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)));
        }
    }
1278370
function (source, options) {
        this.index = this._geIndex(source);
        this.data = '';
        this.options = options;
        this._cache = {};
        this._usedHeaders = [];
    }
118343
def set_headers(self) -> None:
        
        self.set_header("Accept-Ranges", "bytes")
        self.set_etag_header()

        if self.modified is not None:
            self.set_header("Last-Modified", self.modified)

        content_type = self.get_content_type()
        if content_type:
            self.set_header("Content-Type", content_type)

        cache_time = self.get_cache_time(self.path, self.modified, content_type)
        if cache_time > 0:
            self.set_header(
                "Expires",
                datetime.datetime.utcnow() + datetime.timedelta(seconds=cache_time),
            )
            self.set_header("Cache-Control", "max-age=" + str(cache_time))

        self.set_extra_headers(self.path)
964448
public static void setExpiresSeconds(@NotNull HttpServletResponse response, int seconds) {
    Date expiresDate = DateUtils.addSeconds(new Date(), seconds);
    setExpires(response, expiresDate);
  }
274300
@Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain)
            throws IOException, ServletException {
        HttpServletResponse httpServletResponse = (HttpServletResponse) servletResponse;
        StringBuilder cacheControl = new StringBuilder(cacheability.getValue()).append(", max-age=").append(expiration);
        if (mustRevalidate) {
            cacheControl.append(", must-revalidate");
        }

        // Set cache directives
        httpServletResponse.setHeader(HTTPCacheHeader.CACHE_CONTROL.getName(), cacheControl.toString());
        httpServletResponse.setDateHeader(HTTPCacheHeader.EXPIRES.getName(), System.currentTimeMillis() + expiration
                * 1000L);

        // Set Vary field
        if (vary != null && !vary.isEmpty()) {
            httpServletResponse.setHeader(HTTPCacheHeader.VARY.getName(), vary);
        }

        /*
         * By default, some servers (e.g. Tomcat) will set headers on any SSL content to deny caching. Omitting the
         * Pragma header takes care of user-agents implementing HTTP/1.0.
         */
        filterChain.doFilter(servletRequest, new HttpServletResponseWrapper(httpServletResponse) {
            @Override
            public void addHeader(String name, String value) {
                if (!HTTPCacheHeader.PRAGMA.getName().equalsIgnoreCase(name)) {
                    super.addHeader(name, value);
                }
            }

            @Override
            public void setHeader(String name, String value) {
                if (!HTTPCacheHeader.PRAGMA.getName().equalsIgnoreCase(name)) {
                    super.setHeader(name, value);
                }
            }
        });
    }
1300248
function setHeaders($headers){
		$this->debug("setHeaders headers=");
		$this->appendDebug($this->varDump($headers));
		$this->requestHeaders = $headers;
	}