Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

缓存机制 #6

Open
yuandaishi opened this issue Mar 20, 2019 · 0 comments
Open

缓存机制 #6

yuandaishi opened this issue Mar 20, 2019 · 0 comments
Labels
web something about web

Comments

@yuandaishi
Copy link
Owner

yuandaishi commented Mar 20, 2019

因为别人已经总结得很好了,所以我这里就放别人的链接就好了。

  1. HTTP强缓存和协商缓存
  2. HTTP 缓存机制一二三

总之就是:

  1. 浏览器第一次获取文件的时候,不仅存储了这个文件,还存储了相应的头部信息。
  2. 强制缓存:会先从浏览器缓存中找相应的文件,找到了,会用客户端时间和头部缓存信息作对比,没过期,则不会向后端发起请求,直接获取浏览器缓存的数据。
  3. 协商缓存:没有强制缓存的话,会向服务器发起请求,请求头带上上一次返回的协商缓存,请求头的协商缓存和服务器作对比,没过期,则返回新的请求头,不拉取最新文件,状态码304,过期,则返回新的请求头,且从新拉取文件。
@yuandaishi yuandaishi added the web something about web label Mar 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
web something about web
Projects
None yet
Development

No branches or pull requests

1 participant