Commit 50188cd6 authored by clamy@chromium.org's avatar clamy@chromium.org

Use the ReloadBypassingCache policy

This CL makes use of the new ReloadBypassingCache policy and removes the
setting of cache HTTP headers in blink.

BUG=376025

Review URL: https://codereview.chromium.org/318673002

git-svn-id: svn://svn.chromium.org/blink/trunk@175515 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 3dce8758
......@@ -774,12 +774,13 @@ ResourceRequestCachePolicy ResourceFetcher::resourceRequestCachePolicy(const Res
{
if (type == Resource::MainResource) {
FrameLoadType frameLoadType = frame()->loader().loadType();
bool isReload = frameLoadType == FrameLoadTypeReload || frameLoadType == FrameLoadTypeReloadFromOrigin;
if (request.httpMethod() == "POST" && frameLoadType == FrameLoadTypeBackForward)
return ReturnCacheDataDontLoad;
if (!m_documentLoader->overrideEncoding().isEmpty() || frameLoadType == FrameLoadTypeBackForward)
return ReturnCacheDataElseLoad;
if (isReload || frameLoadType == FrameLoadTypeSame || request.isConditional() || request.httpMethod() == "POST")
if (frameLoadType == FrameLoadTypeReloadFromOrigin)
return ReloadBypassingCache;
if (frameLoadType == FrameLoadTypeReload || frameLoadType == FrameLoadTypeSame || request.isConditional() || request.httpMethod() == "POST")
return ReloadIgnoringCacheData;
Frame* parent = frame()->tree().parent();
if (parent && parent->isLocalFrame())
......
......@@ -315,11 +315,8 @@ void InspectorResourceAgent::willSendRequest(unsigned long identifier, DocumentL
request.setReportLoadTiming(true);
request.setReportRawHeaders(true);
if (m_state->getBoolean(ResourceAgentState::cacheDisabled)) {
request.setHTTPHeaderField("Pragma", "no-cache");
request.setCachePolicy(ReloadIgnoringCacheData);
request.setHTTPHeaderField("Cache-Control", "no-cache");
}
if (m_state->getBoolean(ResourceAgentState::cacheDisabled))
request.setCachePolicy(ReloadBypassingCache);
String frameId = m_pageAgent->frameId(loader->frame());
......
......@@ -372,7 +372,7 @@ void DocumentLoader::willSendRequest(ResourceRequest& newRequest, const Resource
// this is a common site technique to return to a page viewing some data that the POST
// just modified.
if (newRequest.cachePolicy() == UseProtocolCachePolicy && isRedirectAfterPost(newRequest, redirectResponse))
newRequest.setCachePolicy(ReloadIgnoringCacheData);
newRequest.setCachePolicy(ReloadBypassingCache);
// If this is a sub-frame, check for mixed content blocking against the top frame.
if (m_frame->tree().parent()) {
......
......@@ -91,16 +91,6 @@ void FrameFetchContext::addAdditionalRequestHeaders(Document* document, Resource
m_frame->loader().applyUserAgent(request);
if (request.cachePolicy() == ReloadIgnoringCacheData
|| request.cachePolicy() == ReloadBypassingCache) {
if (m_frame->loader().loadType() == FrameLoadTypeReload) {
request.setHTTPHeaderField("Cache-Control", "max-age=0");
} else if (m_frame->loader().loadType() == FrameLoadTypeReloadFromOrigin) {
request.setHTTPHeaderField("Cache-Control", "no-cache");
request.setHTTPHeaderField("Pragma", "no-cache");
}
}
if (isMainResource)
request.setHTTPAccept(defaultAcceptHeader);
......
......@@ -786,7 +786,8 @@ void FrameLoader::reload(ReloadPolicy reloadPolicy, const KURL& overrideURL, con
if (!m_currentItem)
return;
ResourceRequest request = requestFromHistoryItem(m_currentItem.get(), ReloadIgnoringCacheData);
ResourceRequestCachePolicy cachePolicy = reloadPolicy == EndToEndReload ? ReloadBypassingCache : ReloadIgnoringCacheData;
ResourceRequest request = requestFromHistoryItem(m_currentItem.get(), cachePolicy);
if (!overrideURL.isEmpty()) {
request.setURL(overrideURL);
request.clearHTTPReferrer();
......
......@@ -5480,4 +5480,16 @@ TEST_F(WebFrameTest, NotifyManifestChange)
EXPECT_EQ(14, webFrameClient.manifestChangeCount());
}
TEST_F(WebFrameTest, ReloadBypassingCache)
{
// Check that a reload ignoring cache on a frame will result in the cache
// policy of the request being set to ReloadBypassingCache.
registerMockedHttpURLLoad("foo.html");
FrameTestHelpers::WebViewHelper webViewHelper;
webViewHelper.initializeAndLoad(m_baseURL + "foo.html", true);
WebFrame* frame = webViewHelper.webView()->mainFrame();
FrameTestHelpers::reloadFrameIgnoringCache(frame);
EXPECT_EQ(WebURLRequest::ReloadBypassingCache, frame->dataSource()->request().cachePolicy());
}
} // namespace
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment