cache-control

HTTP缓存机制

天涯浪子 提交于 2019-12-05 10:04:39
Web 缓存大致可以分为:数据库缓存、服务器端缓存(代理服务器缓存、CDN 缓存)、浏览器缓存。 浏览器缓存也包含很多内容: HTTP 缓存、indexDB、cookie、localstorage 等等。这里我们只讨论 HTTP 缓存相关内容。 在具体了解 HTTP 缓存之前先来明确几个术语: 缓存命中率:从缓存中得到数据的请求数与所有请求数的比率。理想状态是越高越好。 过期内容:超过设置的有效时间,被标记为“陈旧”的内容。通常过期内容不能用于回复客户端的请求,必须重新向源服务器请求新的内容或者验证缓存的内容是否仍然准备。 验证:验证缓存中的过期内容是否仍然有效,验证通过的话刷新过期时间。 失效:失效就是把内容从缓存中移除。当内容发生改变时就必须移除失效的内容。 浏览器缓存主要是 HTTP 协议定义的缓存机制。HTML meta 标签,例如 <META HTTP-EQUIV="Pragma" CONTENT="no-store"> 含义是让浏览器不缓存当前页面。但是代理服务器不解析 HTML 内容,一般应用广泛的是用 HTTP 头信息控制缓存。 浏览器缓存分类 浏览器缓存分为强缓存和协商缓存,浏览器加载一个页面的简单流程如下: 浏览器先根据这个资源的http头信息来判断是否命中强缓存。如果命中则直接加在缓存中的资源,并不会将请求发送到服务器。 如果未命中强缓存

Browser cache expiration for js and css files with wildfly

陌路散爱 提交于 2019-12-05 08:24:42
I have a angularjs javascript app packaged in a webapp deployed to Wildfly 8.2.1. Sometimes, when I deploy javascript or css modifications to this webapp, users have to manually delete their browser cache for the modifications appear. Is there a way to change this behavior so users don't have to delete their browser cache every time? I've shared a Gist article about that. It describes how to configure response headers in wildfly undertow subsytem to tune expiration cache headers in server http response, for specific static contents such as .js, .css, ... files. 来源: https://stackoverflow.com

How do i use Cache Control and ETag to set http headers

耗尽温柔 提交于 2019-12-05 08:09:48
I want to use Cache Control and ETag in my joomla website as suggested by google. But have no idea how to do that. I googled it a lot but could not find any worty example. Can anybody tell me how to do that..?? For Cache Control i have found this example, but is this the complete syntax..?? and where to place it in <head> tag of the index.php file??. Also please tell me the syntax of ETag and the place where to write it. You can use your .htaccess file at the root of your website for this. You'll find lots of variations on the specifics, here's a comprehensive one from http://www.siteground

php eTag generation using php

北城以北 提交于 2019-12-05 07:04:47
问题 This PHP code generates an eTag for an xml file. The problem is eTag updates only when the file it self is updated/modified. I need the etag to update when the dynamic results are updated as well. any idea how this can be done? //get the last-modified-date of this very file $lastModified=filemtime(__FILE__); //get a unique hash of this file (etag) $etagFile = md5_file(__FILE__); //get the HTTP_IF_MODIFIED_SINCE header if set $ifModifiedSince=(isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? $

Symfony2 response - Clear cache headers on back button

南楼画角 提交于 2019-12-05 06:44:29
I have an issue with clearing my cache when back button is pressed. My header information is saying i'ts loaded from cache: Status Code:200 OK (from cache) My response is set to: $response = new Response; $response->expire(); $response->headers->addCacheControlDirective('must-revalidate', true); $response->headers->addCacheControlDirective('allow_reload', true); What am I doing wrong? None of the documentation methods seem to work... Taking advice from this article and setting listed Cache-Control directives worked for me - by pressing back button request to the server was always sent.

Cloudfront cache-control headers missing

守給你的承諾、 提交于 2019-12-05 02:29:21
I setup Cloudfront to serve static images, js, css files for www.lottoresults.ie. I used a custom origin server. The cloudfront domain name I setup is icdn.lottoresults.ie. I set this up using Bind9 dns, with icdn.lottoresults.ie a CNAME for the cloudfront distro. That's all fine. However, for website performance optimization (Yslow, google pagespeed etc), I want to have Cache-control and Expires headers set, and I do not want Etags. To do this, I have the following in my htaccess file for the doc_root of www.lottoresults.ie: Header unset Pragma FileETag none Header unset ETag <FilesMatch "(.*

How can I implement CSS Cache Busting with JSF outputStylesheet?

时光毁灭记忆、已成空白 提交于 2019-12-05 01:37:43
In JSF page templates I use this code to include a CSS resource: <h:outputStylesheet library="css" name="mystyles.css" /> The usual way to implement CSS cache busting would be to add a version parameter, like v=123 , however this is not supported in outputStyleSheet: <h:outputStylesheet library="css" name="mystyles.css?v=123" /> will cause a JSF1064 warning and the CSS will not be found. That's not possible without overridding the StylesheetRenderer (assuming you're on Mojarra). It does indeed not take the query string into account. However, as a (temporary) workaround it's good to know that

Override the “cache-control” values in a HTTP response

好久不见. 提交于 2019-12-04 19:37:03
问题 I have a web page that returns the following header when I access material: HTTP/1.1 200 OK Date: Sat, 29 Jun 2013 15:57:25 GMT Server: Apache Content-Length: 2247515 Cache-Control: no-cache, no-store, must-revalidate, max-age=-1 Pragma: no-cache, no-store Expires: -1 Connection: close Using a chrome extension, I want to modify this response header so that the material is actually cached instead of wasting bandwidth. I have the following sample code: chrome.webRequest.onHeadersReceived

How do I set Meteor to not cache anything for a specific page?

╄→гoц情女王★ 提交于 2019-12-04 16:45:51
I am working on a project where I am using Meteor as an implementation. There are set of pages that are being cached and there's no concern. However, there is one page in the project that I am trying to set for no-cache. How do I achieve that? EDITED: Based on chosen accepted answer; I achieved the desired result with this wrapping code: if (Meteor.isServer) { Meteor.startup(function () { WebApp.rawConnectHandlers.use(function (req, res, next) { res.setHeader('cache-control', 'no-cache'); res.setHeader('expires', '0'); res.setHeader('Content-Type', 'text/html'); res.setHeader('charset', 'utf-8

Which browsers support “Cache-control: immutable”?

谁说胖子不能爱 提交于 2019-12-04 16:25:51
问题 I've read that Firefox has begun supporting a cache control extension value of immutable , which means that "the response body will not change over time." So even if a user requests a "full refresh" of a page or resource, the browser still only responds with the locally cached copy, thus avoiding unnecessary 304s or page refreshes, and making pages load faster since cached content is used, and decreasing load on servers, since a large number of requests are stopped before they even happen. I