New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 643659 link

Starred by 5 users

Issue metadata

Status: Fixed
Owner:
Closed: Sep 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Windows
Pri: 1
Type: Bug-Regression



Sign in to add a comment

resource is not served from the cache after performing explicit conditional request

Reported by alexsuvo...@unity3d.com, Sep 2 2016

Issue description

UserAgent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:43.0) Gecko/20100101 Firefox/43.0

Example URL:
http://files.unity3d.com/alexsuvorov/bugs/chrome-revalidation/

Steps to reproduce the problem:
open http://files.unity3d.com/alexsuvorov/bugs/chrome-revalidation/

1. click the "get" button:
  "test.dat" resource is downloaded using XMLHttpRequest (responseText returns "Hello World!"), revalidation response headers are remembered if present (in this specific case, the "Last-Modified" header is stored in the test.revalidateHeaders)

2. click the "revalidate" button:
  "test.dat" resource is requested with explicitly set "If-Modified-Since" header (using setRequestHeader) having the previously remembered "Last-Modified" value. The server responds with 304 as expected and 304 status is passed to the XMLHttpRequest along with the empty response body as expected.

3. click the "get" button again:
  "test.dat" resource is downloaded using XMLHttpRequest. The procedure is identical to step 1, however, the browser now passes 304 and a zero-length response, even though no additional headers have been set this time (unlike step 2, where such result would be expected)

What is the expected behavior?
Non-conditional requests to an existing resource should return status 200 and a valid response body, regardless of the previously executed conditional requests to the same resource.

What went wrong?
Browser does not pass the cached response body to the XMLHttpRequest after conditional request has been executed for the resource.

Did this work before? Yes Works correctly at least in Chromium 47.0.2516.0

Chrome version: 53.0.2785.89  Channel: stable
OS Version: 10.0
Flash Version: 

The issue is not specific to the mentioned server and can be reproduced on other servers as well. The issue is present in 55.0.2847.0 canary. The issue is not reproducible in recent versions of Firefox or Safari. Reopening the tab fixes the issue.
 
Cc: jkarlin@chromium.org gavinp@chromium.org
Components: -Internals>Network Internals>Network>Cache
[+gavinp, +jkarlin]  Hrm...Maybe some bug in HttpCache::Transaction when the client sets revalidation headers?

This is easy to repro, so don't think we need a net-internals log here.
Status: Untriaged (was: Unconfirmed)
FWIW, in Chrome 39, *if* the XHR is not async, I see the same behavior. 

Perhaps the regression is somehow related related to https://bugs.chromium.org/p/chromium/issues/detail?id=570622 ?
Cc: y...@yoav.ws japhet@chromium.org
Components: Blink>Loader
Good find!  That well could well be related.

[+japhet, +yoav]:  This issue sounds related to  issue 570622 , which you fixed in https://codereview.chromium.org/1558703002.
I think maybe I was mislead by similar symptoms but an unrelated root cause, because the CL in question only seems to have changed the behavior of Sync XHR and that isn't in use in this bug.

For this repro, no matter how many times I hit the GET Button, the Network Events log only contains one URL_REQUEST / DISK_CACHE_ENTRY pair for http://files.unity3d.com/alexsuvorov/bugs/chrome-revalidation/test.dat, until I hit the REVALIDATE Button, which creates its own URL_REQUEST/DISK_CACHE_ENTRY pair every time it is clicked. After that point, for the lifetime of the tab, every click on the GET Button creates another URL_REQUEST/DISK_CACHE_ENTRY pair. 

That suggests to me that there's a memory cache between the XHR and the network stack and it's servicing all of the plain XHR GET requests initially. Then the custom request with the cache-validation headers is made and its response (Warning: guessing here) evicts the original memory cache entry for the resource. At that point, all subsequent requests are deemed to require validation and the If-Modified-Since/ETAG pair is added to the network request which hits the DISK_CACHE entry.
NOT REPRO:
52.0.2733.0 dfad350a05c0affd2819a8e5b8025d50c7aa5508-refs/heads/master@{#393034}

REPRO:
52.0.2733.0 fe8a72da89b1941cccdd54a0da548540360286a6-refs/heads/master@{#393044}

In this range, the likely candidate seems to be https://codereview.chromium.org/1923003002 
Cc: -jkarlin@chromium.org -japhet@chromium.org -gavinp@chromium.org hirosh...@chromium.org yhirano@chromium.org
Components: -Internals>Network>Cache
Labels: -Type-Bug -Pri-2 Pri-1 Type-Bug-Regression
Owner: japhet@chromium.org
Status: Assigned (was: Untriaged)
elawrence:  Thanks for the bisect!  That CL does look a likely culprit.  CCing reviewers, and assigning to patch author.

[japhet]:  Since this wasn't noticed for all of M52, probably not urgent to fix it, but we should probably have a fix in M55, at least.

Comment 7 by kbr@chromium.org, Sep 7 2016

Cc: kbr@chromium.org
Labels: M-55 ReleaseBlock-Stable
Marking R-B-S for M55 since a partner (Unity) discovered this and it's affecting their product.

Project Member

Comment 8 by bugdroid1@chromium.org, Sep 23 2016

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/d343f801f8cd63f985180bb4acb9cd4949e4c4b9

commit d343f801f8cd63f985180bb4acb9cd4949e4c4b9
Author: japhet <japhet@chromium.org>
Date: Fri Sep 23 23:09:24 2016

Don't attempt to revalidate a Resource with a 304 response.

...which is counter-intuitive. Normally, a revalidation is started on a Resource
with a 2xx response. If the revalidation is successful (i.e, a 304 response),
Resource updates it's m_response with the headers that were received on the
304 response, but leaves the original 2xx response status code. A Resource with
a 304 status code on its m_response therefore received the 304 without thinking
it issued a revaldation. This could happen as a result of a server behaving
badly, or it could happen because an XHR was created with manually added
revalidation headers. In either case, the Resource is not guaranteed to have
sufficient information to perform a successful revalidtion, so don't attempt a
revalidation with it.

BUG= 643659 
TEST=ResourceTest.Revalidate304

Review-Url: https://codereview.chromium.org/2341893002
Cr-Commit-Position: refs/heads/master@{#420771}

[modify] https://crrev.com/d343f801f8cd63f985180bb4acb9cd4949e4c4b9/third_party/WebKit/Source/core/fetch/ResourceFetcher.cpp
[modify] https://crrev.com/d343f801f8cd63f985180bb4acb9cd4949e4c4b9/third_party/WebKit/Source/core/fetch/ResourceFetcherTest.cpp

Comment 9 by japhet@chromium.org, Sep 23 2016

Status: Fixed (was: Assigned)

Comment 10 by kbr@chromium.org, Sep 23 2016

Very nice. Thanks Nate for fixing this and adding a regression test.

Sign in to add a comment