Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(212)

Side by Side Diff: Source/core/fetch/ResourceFetcher.cpp

Issue 229053004: Allow cache reuse of some requests with Cache-Control headers (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/fetch/Resource.cpp ('k') | Source/platform/blink_platform.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de)
3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) 3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org)
4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) 4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org)
5 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved. 5 Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights reserved.
6 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/ 6 Copyright (C) 2009 Torch Mobile Inc. http://www.torchmobile.com/
7 7
8 This library is free software; you can redistribute it and/or 8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public 9 modify it under the terms of the GNU Library General Public
10 License as published by the Free Software Foundation; either 10 License as published by the Free Software Foundation; either
(...skipping 884 matching lines...) Expand 10 before | Expand all | Expand 10 after
895 // Always use preloads. 895 // Always use preloads.
896 if (existingResource->isPreloaded()) 896 if (existingResource->isPreloaded())
897 return Use; 897 return Use;
898 898
899 // CachePolicyHistoryBuffer uses the cache no matter what. 899 // CachePolicyHistoryBuffer uses the cache no matter what.
900 CachePolicy cachePolicy = context().cachePolicy(document()); 900 CachePolicy cachePolicy = context().cachePolicy(document());
901 if (cachePolicy == CachePolicyHistoryBuffer) 901 if (cachePolicy == CachePolicyHistoryBuffer)
902 return Use; 902 return Use;
903 903
904 // Don't reuse resources with Cache-control: no-store. 904 // Don't reuse resources with Cache-control: no-store.
905 if (existingResource->response().cacheControlContainsNoStore()) { 905 if (existingResource->hasCacheControlNoStoreHeader()) {
906 WTF_LOG(ResourceLoading, "ResourceFetcher::determineRevalidationPolicy r eloading due to Cache-control: no-store."); 906 WTF_LOG(ResourceLoading, "ResourceFetcher::determineRevalidationPolicy r eloading due to Cache-control: no-store.");
907 return Reload; 907 return Reload;
908 } 908 }
909 909
910 // If fetching a resource with a different 'CORS enabled' flag, reload. 910 // If fetching a resource with a different 'CORS enabled' flag, reload.
911 if (type != Resource::MainResource && options.corsEnabled != existingResourc e->options().corsEnabled) 911 if (type != Resource::MainResource && options.corsEnabled != existingResourc e->options().corsEnabled)
912 return Reload; 912 return Reload;
913 913
914 // If credentials were sent with the previous request and won't be 914 // If credentials were sent with the previous request and won't be
915 // with this one, or vice versa, re-fetch the resource. 915 // with this one, or vice versa, re-fetch the resource.
(...skipping 27 matching lines...) Expand all
943 if (existingResource->isLoading()) 943 if (existingResource->isLoading())
944 return Use; 944 return Use;
945 945
946 // If any of the redirects in the chain to loading the resource were not cac heable, we cannot reuse our cached resource. 946 // If any of the redirects in the chain to loading the resource were not cac heable, we cannot reuse our cached resource.
947 if (!existingResource->canReuseRedirectChain()) { 947 if (!existingResource->canReuseRedirectChain()) {
948 WTF_LOG(ResourceLoading, "ResourceFetcher::determineRevalidationPolicy r eloading due to an uncacheable redirect"); 948 WTF_LOG(ResourceLoading, "ResourceFetcher::determineRevalidationPolicy r eloading due to an uncacheable redirect");
949 return Reload; 949 return Reload;
950 } 950 }
951 951
952 // Check if the cache headers requires us to revalidate (cache expiration fo r example). 952 // Check if the cache headers requires us to revalidate (cache expiration fo r example).
953 if (cachePolicy == CachePolicyRevalidate || existingResource->mustRevalidate DueToCacheHeaders()) { 953 if (cachePolicy == CachePolicyRevalidate || existingResource->mustRevalidate DueToCacheHeaders()
954 || request.cacheControlContainsNoCache()) {
954 // See if the resource has usable ETag or Last-modified headers. 955 // See if the resource has usable ETag or Last-modified headers.
955 if (existingResource->canUseCacheValidator()) 956 if (existingResource->canUseCacheValidator())
956 return Revalidate; 957 return Revalidate;
957 958
958 // No, must reload. 959 // No, must reload.
959 WTF_LOG(ResourceLoading, "ResourceFetcher::determineRevalidationPolicy r eloading due to missing cache validators."); 960 WTF_LOG(ResourceLoading, "ResourceFetcher::determineRevalidationPolicy r eloading due to missing cache validators.");
960 return Reload; 961 return Reload;
961 } 962 }
962 963
963 return Use; 964 return Use;
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after
1400 case Revalidate: 1401 case Revalidate:
1401 ++m_revalidateCount; 1402 ++m_revalidateCount;
1402 return; 1403 return;
1403 case Use: 1404 case Use:
1404 ++m_useCount; 1405 ++m_useCount;
1405 return; 1406 return;
1406 } 1407 }
1407 } 1408 }
1408 1409
1409 } 1410 }
OLDNEW
« no previous file with comments | « Source/core/fetch/Resource.cpp ('k') | Source/platform/blink_platform.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698