zoukankan      html  css  js  c++  java
  • 缓存、策略、时间

    缓存:数据+操作说明(时间、标示符号)(符合数据结构+算法的理论)

    操作算法由协议层实现。

    客户端:缓存检查、缓存管理;

    检查数据是否过时,未过时使用本地数据,否则删除本地数据。

    关于 Cache-Control: max-age=秒 和 Expires

    Expires = 时间,HTTP 1.0 版本,缓存的载止时间,允许客户端在这个时间之前不去检查(发请求)
    max-age = 秒,HTTP 1.1版本,资源在本地缓存多少秒。
    如果max-age和Expires同时存在,则被Cache-Control的max-age覆盖。

    服务器:请求检查、缓存更新。

    比对数据标示和时间,如果有修改,向客户端发送最新数据。否则发304状态。

    缓存处理机制由协议层实现,不需要开发者介入。

    缺省的缓存处理机制由协议层实现。不需要开发者开发。只需要设置响应的标示位即可。

    Last-Modified和Etag头都是由WebServer发出的HttpReponse Header,WebServer应该同时支持这两种头。

    The most complicated cache use situation is when a request uses the HTTP protocol and has set the cache policy to NSURLRequestUseProtocolCachePolicy.

    If an NSCachedURLResponse does not exist for the request, then the URL loading system fetches the data from the originating source.

    If a cached response exists for the request, the URL loading system checks the response to determine if it specifies that the contents must be revalidated.

    If the contents must be revalidated, the URL loading system makes a HEAD request to the originating source to see if the resource has changed. If it has not changed, then the URL loading system returns the cached response. If it has changed, the URL loading system fetches the data from the originating source.

    If the cached response doesn’t specify that the contents must be revalidated, the URL loading system examines the maximum age or expiration specified in the cached response. If the cached response is recent enough, then the URL loading system returns the cached response. If the response is stale, the URL loading system makes a HEAD request to the originating source to determine whether the resource has changed. If so, the URL loading system fetches the resource from the originating source. Otherwise, it returned the cached response.

  • 相关阅读:
    腾讯本月将出QQ for Linux!
    OpenSolaris 初体验
    OpenSolaris 初体验
    简易背单词
    NetBeans 全球翻译团队Tshirt发放~
    上传图片时预览效果
    使用ATL开发ActiveX控件
    Visual Studio 2010 Visual C++ 确定要重新分发的 DLL
    动态链接导入库与静态链接库
    20110413 15:54 利用事件触发实现ActiveX调用js函数
  • 原文地址:https://www.cnblogs.com/feng9exe/p/7203509.html
Copyright © 2011-2022 走看看