• 缓存、策略、时间


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

    操作算法由协议层实现。

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

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

    关于 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.

  • 相关阅读:
    Linux下的C编程实战之文件系统编程
    IPMSG在ubuntu linux上的安装
    NTP服务器
    [Multimedia][MPEG2]MPEG2系统原理
    BitOperation.cs
    android interview 1
    Android USB Host
    android interview 3
    someone's android note
    Android Afianl框架(1)——FinalActivity注解
  • 原文地址:https://www.cnblogs.com/feng9exe/p/7203509.html
Copyright © 2020-2023  润新知