Meta标签中的http-equiv用来标记不可缓存或过期时间,但效果一般。而且代理缓存基本不访问HTML文档内容,所以尽量少用meta标签控制缓存。

Pragma: no-cache

Forces caches to submit the request to the origin server for validation before releasing a cached copy.

Pragma is not specified for HTTP responses .Use[a1]  Pragma only for backwards compatibility with HTTP/1.0 clients.

Cache-Control

used to specify directives for caching mechanisms in both, requests and responses. Caching directives are unidirectional(单向), meaning that a given directive in a request is not implying that the same directive is to be given in the response.

通用指令

Cache-Control: max-age=<seconds>

Specifies the maximum amount of time a resource will be considered fresh. Contrary to Expires, this directive is relative to the time of the request.

Cache-Control: no-cache(数据会被缓存)

Forces caches to submit the request to the origin server for validation before releasing a cached copy.

Cache-Control: no-store

The cache should not store anything about the client request or server response.

Cache-Control: no-transform

Cache-Control: max-age=<seconds>

request指令

Cache-Control: max-stale[=<seconds>]

Cache-Control: min-fresh=<seconds>

Cache-Control: only-if-cached

response指令

Cache-Control: must-revalidate

The cache must verify the status of the stale resources before using it and expired ones should not be used.

Cache-Control: public

Cache-Control: private

Cache-Control: proxy-revalidate

Cache-Control: s-maxage=<seconds>

Expires: <http-date>

The Expires header contains the date/time after which the response is considered stale.

Invalid dates, like the value 0, represent a date in the past and mean that the resource is already expired.

If there is a Cache-Control header with the "max-age" or "s-max-age" directive in the response, the Expires header is ignored.


[a1]请求缓存和响应缓存有什么不同???

带条件请求和无条件请求

An unconditional request is made when the client browser does not have a cached copy of the resource available locally. In this case, the server is expected to return the resource with a HTTP/200 OK response. If the response’s headers permit it, the client may cache this response in order to reuse it later.
If the browser later needs a resource which is in the cache, but that response is expired (older than its max-age or past the Expires date), then the client will make a conditional request to the server to determine whether the previously cached response is still valid and should be reused. The conditional request contains an If-Modified-Since and/or If-None-Match header that indicates to the server what version of the content the browser already has in its cache. The server can indicate that the client’s copy is still fresh by returning HTTP/304 Not Modified headers with no body, or it can indicate that the client’s copy is stale by returning a HTTP/200 OK response with the new version of the resource.
In the first case (Normal-Refresh,F5), we will perform HTTP requests (conditional, if possible) to revalidate all of the resources on the page, regardless of freshness.In the second case (Super-Refresh,Ctrl+F5,强制刷新), we perform unconditional HTTP requests to redownload all of the content on the page, bypassing the cache altogether.

区分响应是来自原始服务器还是代理服务器?

The Date general-header field represents the date and time at which the message(报文) was originated.
The Age header contains the time in seconds the object has been in a proxy cache. If it is Age: 0, it was probably just fetched from the origin server; otherwise It is usually calculated as a difference between the proxy's current date and the Date general header included in the HTTP response.

200 OK (from cache) vs 304 Not Modified

200 OK (from cache)  是浏览器没有跟服务器确认,直接用了浏览器缓存,最快。一般在expires/max-age头部有效时不会发送请求。因为请求根本没有产生,所以在chrome下请求头部会显示:Provisional headers are shown
304 Not Modified 是浏览器和服务器确认了一次缓存的有效性,再使用缓存,多一次确认(If-Modified-Since/etag)请求。

为什么有"Last-Modified"时也会有200 OK from cache
不同的浏览器会根据不同的用户行为(刷新/强制刷新)对请求添加不同的头部,对响应采用不同的缓存策略。
When "Expires" and "Cache-Control" headers are not specified, but a "Last-Modified" header is specified, browsers have to guess at how long they should keep the document in cache. Some browsers do use algorithms that let the page remain in cache for a day or more.

200 OK (from cache)原因的更多相关文章

  1. [web] 200 OK (from cache) 与 304 Not Modified

    为什么有的缓存是 200 OK (from cache),有的缓存是 304 Not Modified 呢?很简单,看运维是否移除了 Entity Tag.移除了,就总是 200 OK (from c ...

  2. [转]200 OK (from cache) 与 304 Not Modified------没有这个规则(ETag是否移除)!!!from cache和304,请查看顶部的流程图!

    //========没有这个规则(ETag是否移除) 20160422============// 200 OK (from cache) 与 304 Not Modified 为什么有的缓存是 20 ...

  3. [HTTP Protocol] 200 OK (from cache)和304 Not Modified

    含义 200 OK (from cache)直接从缓存中获取的内容并未请求服务器 304 Not Modified 请求服务器并和服务器比较 If-Modified-Since,若文件未改变,服务器返 ...

  4. 200 OK (from cache) 与 304 Not Modified

    解释: 200 OK (from cache)  是浏览器没有跟服务器确认,直接用了浏览器缓存: 304 Not Modified 是浏览器和服务器多确认了一次缓存有效性,再用的缓存. 触发区别: 2 ...

  5. 200 from memory cache / from disk cache / 304 Not Modified 区别

    三者情况有什么区别和联系,什么情况下会发生200 from memory cache 或 200 from disk cache 或 304 Not Modified? 200 from memory ...

  6. 200 ok 几种状态

    浏览器加载资源成功一般会有几种状态 200 ok   ----  从原始服务器请求成功 200 ok from cache    ---- 200 ok from disk cache  ---- 2 ...

  7. 【Android】Android import和export使用说明 及 export报错:jarlist.cache: Resource is out of sync with the file syst解决

    在Android开发export项目时发现有时会报错,内容如下: Problems were encountered during export:  Error exporting PalmIdent ...

  8. 浏览器缓存(Web Cache/ Http Cache)

    浏览器缓存(Web Cache/ Http Cache)是前端性能优化中很重要的组成部分. 缓存策略 浏览器的缓存策略是: 1.如果本地没有缓存,则发送非条件性请求. 2.如果本地有缓存,则判断本地缓 ...

  9. form memory cache、form disk cache与304

    200 from memory cache 不访问服务器,直接读缓存,从内存中读取缓存.此时的数据时缓存到内存中的,当kill进程后,数据将不存在200 from disk cache 不访问服务器, ...

随机推荐

  1. WPF之路一:相对路径图片显示

    由于公司项目的需要,改为WPF开发,因此需要学习WPF,遇到的第一个问题就是在显示的图片的时候,写绝对路径,图片显示没有问题,但是写相对路径的时候,发现图片无法正常显示,在网上搜了一下,得到的答案是需 ...

  2. 老李推荐:第6章7节《MonkeyRunner源码剖析》Monkey原理分析-事件源-事件源概览-注入按键事件实例

    老李推荐:第6章7节<MonkeyRunner源码剖析>Monkey原理分析-事件源-事件源概览-注入按键事件实例   poptest是国内唯一一家培养测试开发工程师的培训机构,以学员能胜 ...

  3. win8如何显示文件后缀名

    按快捷键[WIN+X]然后点击[文件资源管理器]   进入我的电脑后点击菜单栏的[查看]   查看下面有一个[文件扩展名]把前面那个勾,勾上就可以显示后缀名了.   同样的道理取消勾就是隐藏后缀名. ...

  4. DC平衡双向控制解串器 转接IC GM8914:FPD-LINK III转LVTTL芯片

    1 概述 GM8914型DC平衡双向控制解串器,其主要功能是实现将2.8Gbps高速串行数据转换成10或12位并行控制信号,并同步输出一路时钟信号:同时低速通道将芯片控制信息调制到高速差分信号上传输给 ...

  5. Nginx基础学习(一)—Nginx的安装

    一.Nginx介绍 1.什么是Nginx?      Nginx是一款高性能的http 服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器.由俄罗斯的程序设计师Igor Sysoev所开 ...

  6. 在ElasticSearch中使用 IK 中文分词插件

    我这里集成好了一个自带IK的版本,下载即用, https://github.com/xlb378917466/elasticsearch5.2.include_IK 添加了IK插件意味着你可以使用ik ...

  7. 基于MVC和Bootstrap的权限框架解决方案 一.搭建HTML

    因为某些原因,因为需要,最新要做一套客户管理系统,但是不满足于仅有的框架. 看了很多大牛写的框架,强大是强大,代码也太TM多了,乱七八糟话不多说,开始吧 随便在网上找到一套好看的HTML,看起来还不错 ...

  8. jquery 中 eq()遍历方法 和:eq()选择器的区别

    <!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...

  9. MongoDB系列:把mongodb作为windows的服务来启动

    1.首先切换到mongodb安装目录下的bin目录,在控制台直接运行以下命令 "C:\Program Files\MongoDB\Server\3.0\bin\mongod.exe" ...

  10. JQ实现选中以后就左右移动

    <head> <meta charset="utf-8" /> <title>select_option移动</title> < ...