Why isn't 301 Cached?

In this test result, google.com is hit twice. It is getting a 301 redirect to www.google.com but on the repeat view, the browser is not using the cached redirect and attempts to hit google.com.

See http://www.webpagetest.org/result/130701_WE_120c0eebbc411e62a4fd367f426a31b1/

Why isn’t the cached redirect used on the repeat view? My hunch is that despite the Expires and Cache-Control headers, it is lacking either an E-Tag or Last-Modified header. Is that the case here? Could this be an oversight?

Response headers:

HTTP/1.1 301 Moved Permanently Location: http://www.google.com/ Content-Type: text/html; charset=UTF-8 Date: Mon, 01 Jul 2013 05:10:44 GMT Expires: Wed, 31 Jul 2013 05:10:44 GMT Cache-Control: public, max-age=2592000 Server: gws Content-Length: 219 X-XSS-Protection: 1; mode=block X-Frame-Options: SAMEORIGIN

What happens in the other browsers?

That’s really bizarre. Initially I thought it might be an issue with getting data from dev tools and accidentally showing a request from cache but the timings and tcpdump show that it really is hitting the wire: CS Personal on cloudshark.org

IE9: http://www.webpagetest.org/result/130701_VJ_cb5fa18c9229dcde1e5ae22151c58c09/
and Firefox: http://www.webpagetest.org/result/130701_VM_986521861f96e283383f77453bfdb2c5/

are both caching it as you’d expect.

Going to take some more digging to verify that it isn’t something with how WPT runs the tests but it looks like a caching bug in Chrome to me. If so that would be a really good find.

Hey Pat, remember this? I just reran the test and seeing the same results: http://www.webpagetest.org/result/150323_HJ_1568db680e099608e9b4f508dcd1991d/

Now we have a 301 to www and a 302 to https that are not showing up as cached in the repeat view.

Good question. Needs a little validating to be sure it’s not something WPT is doing but looks like a Chrome bug.

Looks like a bug and Canary still has the same issue (Firefox and IE 11 correctly cache it). Just filed a Chrome bug on it: 469675 - chromium - An open-source project to help move the web forward. - Monorail