• Cookies and Caching Client Identification


    w

    HTTP The Definitive Guide

    11.6.9 Cookies and Caching
    You have to be careful when caching documents that are involved with cookie transactions. You don't
    want to assign one user some past user's cookie or, worse, show one user the contents of someone
    else's personalized document.
    The rules for cookies and caching are not well established. Here are some guiding principles for
    dealing with caches:
    Mark documents uncacheable if they are

    The document owner knows best if a document is uncacheable. Explicitly mark documents
    uncacheable if they are—specifically, use Cache-Control: no-cache="Set-Cookie" if the
    document is cacheable except for the Set-Cookie header. The other, more general practice of
    using Cache-Control: public for documents that are cacheable promotes bandwidth savings in
    the Web. Be cautious about caching Set-Cookie headers
    If a response has a Set-Cookie header, you can cache the body (unless told otherwise), but
    you should be extra cautious about caching the Set-Cookie header. If you send the same Set-
    Cookie header to multiple users, you may be defeating user targeting.
    Some caches delete the Set-Cookie header before storing a response in the cache, but that also
    can cause problems, because clients served from the cache will no longer get cookies slapped
    on them that they normally would without the cache. This situation can be improved by
    forcing the cache to revalidate every request with the origin server and merging any returned
    Set-Cookie headers with the client response. The origin server can dictate such revalidations
    by adding this header to the cached copy:
    Cache-Control: must-revalidate, max-age=0
    More conservative caches may refuse to cache any response that has a Set-Cookie header,
    even though the content may actually be cacheable. Some caches allow modes when Set-
    Cookied images are cached, but not text.
    Be cautious about requests with Cookie headers
    When a request arrives with a Cookie header, it provides a hint that the resulting content
    might be personalized. Personalized content must be flagged uncacheable, but some servers
    may erroneously not mark this content as uncacheable.
    Conservative caches may choose not to cache any document that comes in response to a
    request with a Cookie header. And again, some caches allow modes when Cookied images
    are cached, but not text. The more accepted policy is to cache images with Cookie headers,
    with the expiration time set to zero, thus forcing a revalidate every time.

  • 相关阅读:
    学习asp.net完整步骤
    UltraEdit中Matlab语法高亮显示的操作方法
    C#基础完成和深入
    75道程序员面试逻辑思维题
    模拟退火算法解决函数优化问题
    模拟退火算法解决TSP问题
    C#入门
    简单感知器模型解决简单真值表问题
    jQuery 1.3.2 :visible选择器问题
    NUnit2.0详细使用方法
  • 原文地址:https://www.cnblogs.com/rsapaper/p/6396879.html
Copyright © 2020-2023  润新知