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

Unified Diff: Source/core/fetch/Resource.cpp

Issue 232993004: Reland "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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/fetch/Resource.h ('k') | Source/core/fetch/ResourceFetcher.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/fetch/Resource.cpp
diff --git a/Source/core/fetch/Resource.cpp b/Source/core/fetch/Resource.cpp
index 03711f8b7359aa6eed7948e66e85f5462a748184..fb9c614e77538a7ef09ea2bb1cf1bfe31ee8e430 100644
--- a/Source/core/fetch/Resource.cpp
+++ b/Source/core/fetch/Resource.cpp
@@ -282,7 +282,7 @@ static double currentAge(const ResourceResponse& response, double responseTimest
return correctedReceivedAge + residentTime;
}
-static double freshnessLifetime(const ResourceResponse& response, double responseTimestamp)
+static double freshnessLifetime(ResourceResponse& response, double responseTimestamp)
{
#if !OS(ANDROID)
// On desktop, local files should be reloaded in case they change.
@@ -311,7 +311,7 @@ static double freshnessLifetime(const ResourceResponse& response, double respons
return 0;
}
-static bool canUseResponse(const ResourceResponse& response, double responseTimestamp)
+static bool canUseResponse(ResourceResponse& response, double responseTimestamp)
{
if (response.isNull())
return false;
@@ -493,7 +493,7 @@ void Resource::removeClient(ResourceClient* client)
// "no-store: ... MUST make a best-effort attempt to remove the information from volatile storage as promptly as possible"
// "... History buffers MAY store such responses as part of their normal operation."
// We allow non-secure content to be reused in history, but we do not allow secure content to be reused.
- if (response().cacheControlContainsNoStore() && url().protocolIs("https")) {
+ if (hasCacheControlNoStoreHeader() && url().protocolIs("https")) {
memoryCache()->remove(this);
memoryCache()->prune();
} else {
@@ -742,28 +742,35 @@ void Resource::unregisterHandle(ResourcePtrBase* h)
}
}
-bool Resource::canReuseRedirectChain() const
+bool Resource::canReuseRedirectChain()
{
for (size_t i = 0; i < m_redirectChain.size(); ++i) {
if (!canUseResponse(m_redirectChain[i].m_redirectResponse, m_responseTimestamp))
return false;
+ if (m_redirectChain[i].m_request.cacheControlContainsNoCache() || m_redirectChain[i].m_request.cacheControlContainsNoStore())
+ return false;
}
return true;
}
-bool Resource::mustRevalidateDueToCacheHeaders() const
+bool Resource::hasCacheControlNoStoreHeader()
+{
+ return m_response.cacheControlContainsNoStore() || m_resourceRequest.cacheControlContainsNoStore();
+}
+
+bool Resource::mustRevalidateDueToCacheHeaders()
{
- return !canUseResponse(m_response, m_responseTimestamp);
+ return !canUseResponse(m_response, m_responseTimestamp) || m_resourceRequest.cacheControlContainsNoCache() || m_resourceRequest.cacheControlContainsNoStore();
}
-bool Resource::canUseCacheValidator() const
+bool Resource::canUseCacheValidator()
{
if (m_loading || errorOccurred())
return false;
- if (m_response.cacheControlContainsNoStore())
+ if (hasCacheControlNoStoreHeader())
return false;
- return m_response.hasCacheValidatorFields();
+ return m_response.hasCacheValidatorFields() || m_resourceRequest.hasCacheValidatorFields();
}
bool Resource::isPurgeable() const
« no previous file with comments | « Source/core/fetch/Resource.h ('k') | Source/core/fetch/ResourceFetcher.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698