Changeset 72303 in webkit


Ignore:
Timestamp:
Nov 18, 2010 9:59:53 AM (13 years ago)
Author:
Joseph Pecoraro
Message:

2010-11-18 Joseph Pecoraro <Joseph Pecoraro>

Reviewed by Darin Adler.

Allow no-store resources to be used for back navigation
https://bugs.webkit.org/show_bug.cgi?id=49672

Add tests for checking if the cache was used for a "Cache-control: no-store"
resource in back navigation, reload navigation, and normal navigation.

  • http/tests/cache/history-only-cached-subresource-loads-expected.txt: Added.
  • http/tests/cache/history-only-cached-subresource-loads.html: Added.
  • http/tests/cache/resources/no-store-resource-forward.html: Added.
  • http/tests/cache/resources/no-store-resource-next.html: Added.
  • http/tests/cache/resources/no-store-resource.html: Added.
  • http/tests/cache/resources/random.cgi: Added.

2010-11-18 Joseph Pecoraro <Joseph Pecoraro>

Reviewed by Darin Adler.

Allow no-store resources to be used for back navigation
https://bugs.webkit.org/show_bug.cgi?id=49672

Test: http/tests/cache/history-only-cached-subresource-loads.html

HTTP allows "Cache-Control: no-store" resources to "cached" for the
purposes of history, such as back/forward navigation. Previously
WebCore just immediately evicted these resources, now we leave them in
the cache as long as they are not "https". This allows us to use them
if they are used in a back navigation, or lazily evict and replace
them on other load types expecting non-stale resources.

(WebCore::CachedResource::CachedResource):
(WebCore::CachedResource::removeClient): instead of immediately removing the resource from the cache, leave it in the cache.

  • loader/cache/CachedResourceLoader.cpp: (WebCore::CachedResourceLoader::checkForReload): (WebCore::CachedResourceLoader::requestResource): allow history only resources if the CachePolicy is CachePolicyHistoryBuffer (back/forward navigation).
  • loader/cache/MemoryCache.cpp: (WebCore::MemoryCache::requestResource): lazily remove history only resources if it is requested for a load type expecting non-stale resources.
  • loader/cache/MemoryCache.h: default the forHistory parameter to false.

Rename cache policy CachePolicyAllowStale to CachePolicyHistoryBuffer.

  • loader/FrameLoader.cpp: (WebCore::FrameLoader::subresourceCachePolicy):
  • loader/cache/CachePolicy.h:
  • loader/cache/CachedResource.cpp:
Location:
trunk
Files:
6 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r72302 r72303  
     12010-11-18  Joseph Pecoraro  <joepeck@webkit.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        Allow no-store resources to be used for back navigation
     6        https://bugs.webkit.org/show_bug.cgi?id=49672
     7
     8        Add tests for checking if the cache was used for a "Cache-control: no-store"
     9        resource in back navigation, reload navigation, and normal navigation.
     10
     11        * http/tests/cache/history-only-cached-subresource-loads-expected.txt: Added.
     12        * http/tests/cache/history-only-cached-subresource-loads.html: Added.
     13        * http/tests/cache/resources/no-store-resource-forward.html: Added.
     14        * http/tests/cache/resources/no-store-resource-next.html: Added.
     15        * http/tests/cache/resources/no-store-resource.html: Added.
     16        * http/tests/cache/resources/random.cgi: Added.
     17
    1182010-11-18  Tony Chang  <tony@chromium.org>
    219
  • trunk/WebCore/ChangeLog

    r72301 r72303  
     12010-11-18  Joseph Pecoraro  <joepeck@webkit.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        Allow no-store resources to be used for back navigation
     6        https://bugs.webkit.org/show_bug.cgi?id=49672
     7
     8        Test: http/tests/cache/history-only-cached-subresource-loads.html
     9
     10        HTTP allows "Cache-Control: no-store" resources to "cached" for the
     11        purposes of history, such as back/forward navigation. Previously
     12        WebCore just immediately evicted these resources, now we leave them in
     13        the cache as long as they are not "https". This allows us to use them
     14        if they are used in a back navigation, or lazily evict and replace
     15        them on other load types expecting non-stale resources.
     16
     17        (WebCore::CachedResource::CachedResource):
     18        (WebCore::CachedResource::removeClient): instead of immediately removing the resource from the cache, leave it in the cache.
     19        * loader/cache/CachedResourceLoader.cpp:
     20        (WebCore::CachedResourceLoader::checkForReload):
     21        (WebCore::CachedResourceLoader::requestResource): allow history only resources if the CachePolicy is CachePolicyHistoryBuffer (back/forward navigation).
     22        * loader/cache/MemoryCache.cpp:
     23        (WebCore::MemoryCache::requestResource): lazily remove history only resources if it is requested for a load type expecting non-stale resources.
     24        * loader/cache/MemoryCache.h: default the forHistory parameter to false.
     25
     26          Rename cache policy CachePolicyAllowStale to CachePolicyHistoryBuffer.
     27
     28        * loader/FrameLoader.cpp:
     29        (WebCore::FrameLoader::subresourceCachePolicy):
     30        * loader/cache/CachePolicy.h:
     31        * loader/cache/CachedResource.cpp:
     32
    1332010-11-18  Alexey Proskuryakov  <ap@apple.com>
    234
  • trunk/WebCore/loader/FrameLoader.cpp

    r72137 r72303  
    23202320
    23212321    if (request.cachePolicy() == ReturnCacheDataElseLoad)
    2322         return CachePolicyAllowStale;
     2322        return CachePolicyHistoryBuffer;
    23232323
    23242324    return CachePolicyVerify;
  • trunk/WebCore/loader/cache/CachePolicy.h

    r71496 r72303  
    3434        CachePolicyRevalidate,
    3535        CachePolicyReload,
    36         CachePolicyAllowStale
     36        CachePolicyHistoryBuffer
    3737    };
    3838
  • trunk/WebCore/loader/cache/CachedResource.cpp

    r72230 r72303  
    253253        if (response().cacheControlContainsNoStore()) {
    254254            // RFC2616 14.9.2:
    255             // "no-store: ...MUST make a best-effort attempt to remove the information from volatile storage as promptly as possible"
    256             cache()->remove(this);
     255            // "no-store: ... MUST make a best-effort attempt to remove the information from volatile storage as promptly as possible"
     256            // "... History buffers MAY store such responses as part of their normal operation."
     257            // We allow non-secure content to be reused in history, but we do not allow secure content to be reused.
     258            if (protocolIs(url(), "https"))
     259                cache()->remove(this);
    257260        } else
    258261            cache()->prune();
  • trunk/WebCore/loader/cache/CachedResourceLoader.cpp

    r71503 r72303  
    114114        cache()->revalidateResource(existing, this);
    115115        break;
    116     case CachePolicyAllowStale:
     116    case CachePolicyHistoryBuffer:
    117117        return;
    118118    }
     
    264264    checkForReload(fullURL);
    265265
    266     CachedResource* resource = cache()->requestResource(this, type, fullURL, charset, isPreload);
     266    bool allowForHistoryOnlyResources = cachePolicy() == CachePolicyHistoryBuffer;
     267    CachedResource* resource = cache()->requestResource(this, type, fullURL, charset, isPreload, allowForHistoryOnlyResources);
    267268    if (resource) {
    268269        // Check final URL of resource to catch redirects.
  • trunk/WebCore/loader/cache/MemoryCache.cpp

    r71503 r72303  
    9595}
    9696
    97 CachedResource* MemoryCache::requestResource(CachedResourceLoader* cachedResourceLoader, CachedResource::Type type, const KURL& url, const String& charset, bool requestIsPreload)
    98 {
    99     LOG(ResourceLoading, "MemoryCache::requestResource '%s', charset '%s', preload=%u", url.string().latin1().data(), charset.latin1().data(), requestIsPreload);
     97CachedResource* MemoryCache::requestResource(CachedResourceLoader* cachedResourceLoader, CachedResource::Type type, const KURL& url, const String& charset, bool requestIsPreload, bool forHistory)
     98{
     99    LOG(ResourceLoading, "MemoryCache::requestResource '%s', charset '%s', preload=%u, forHistory=%u", url.string().latin1().data(), charset.latin1().data(), requestIsPreload, forHistory);
    100100
    101101    // FIXME: Do we really need to special-case an empty URL?
     
    106106    // Look up the resource in our map.
    107107    CachedResource* resource = resourceForURL(url.string());
     108
     109    // Non https "no-store" resources are left in the cache to be used for back/forward navigation only.
     110    // If this is not a request forHistory and the resource was served with "no-store" we should evict
     111    // it here and make a fresh request.
     112    if (!forHistory && resource && resource->response().cacheControlContainsNoStore()) {
     113        LOG(ResourceLoading, "MemoryCache::requestResource cleared a for history only resource due to a non-history request for the resource");
     114        evict(resource);
     115        resource = 0;
     116    }
    108117
    109118    if (resource && requestIsPreload && !resource->isPreloaded()) {
  • trunk/WebCore/loader/cache/MemoryCache.h

    r71499 r72303  
    110110    // Request resources from the cache.  A load will be initiated and a cache object created if the object is not
    111111    // found in the cache.
    112     CachedResource* requestResource(CachedResourceLoader*, CachedResource::Type, const KURL& url, const String& charset, bool isPreload = false);
     112    CachedResource* requestResource(CachedResourceLoader*, CachedResource::Type, const KURL& url, const String& charset, bool isPreload = false, bool forHistory = false);
    113113
    114114    CachedCSSStyleSheet* requestUserCSSStyleSheet(CachedResourceLoader*, const String& url, const String& charset);
Note: See TracChangeset for help on using the changeset viewer.