[webkit-dev] WebKit cache of non-http resources

Mihnea-Vlad Ovidenie mihnea at adobe.com
Mon Mar 22 05:36:49 PDT 2010


Hi there,

WebKit Bug "13128: Safari not obeying cache header" changed the way non-http resources are cached in WebKit. A comment from Antti Koivisto mentioned that, aside from the RFC2616 changes, there is "one additional change that gives non-HTTP resources long cache lifetime. This matches existing behavior."

I have the following scenario:

<html>
<head>
	<script>
    	function reloadFrameByDocumentWrite() {
        var frameDocument = document.getElementById('ID1').contentWindow.document;
        frameDocument.open();
        frameDocument.write("<img src='pic.png' />");
        frameDocument.close();
    	}
	</script>
</head>
<body>
    <input type="button" value="Reload" onclick="reloadFrameByDocumentWrite();" />
    <iframe id="ID1"></iframe>
</body>
</html>

When I load the above code in WebKit and hit "Reload", the picture is displayed into frame ID1. If I change the content of *pic.png* picture while the page is loaded in WebKit and I press "Reload" button again, the frame does not display the updated content of the picture from the local disk.

I took a look at the changelist 44452 and in WebCore\loader\CachedResource.cpp 
double CachedResource::freshnessLifetime() const 
{ 
	// Cache non-http resources liberally 
 	if (!m_response.url().protocolInHTTPFamily()) 
 		return std::numeric_limits<double>::max();

	...
}

This means that in cases like the one described above, since the *pic.png* has protocol *file*, it will be cached for a long time and the new content will not be displayed.

This is different than Safari 4.0 beta and Safari 3.2.1 on Windows. I was wondering what should be the right behavior here since I was not able to find that in RFC 2616? FF3.5.7 works like WebKit/Chrome/Safari 4.0.5. IE8 displays the updated image.

Regards,
Mihnea Ovidenie


More information about the webkit-dev mailing list