What would cause Firefox to request a resource multiple times after executing an external script?
I'm noticing some unusual behavior in Firefox when I include an image directly after a call to an external script.
For example:
<html>
<body>
<script type="text/javascript" src='external.js'></script>
<img src="/test.gif" BORDER=0 WIDTH=1 HEIGHT=1 >
</body>
</html>
"external.js" can be anything at all...even completely blank.
I notice that when a request to test.gif results in a 404 or 302, Firefox makes another request for that same resource immediately after the script has completed.
127.0.0.1 - - [29/Apr/2011:16:22:22 -0400] "GET /test.gif HTTP/1.1" 404 507
127.0.0.1 - - [29/Apr/2011:16:22:22 -0400] "GET /test.gif HTTP/1.1" 404 507
This behavior doesn't occur for inline javascript, and I have pipelining turned off, so I'm fairly certain it's not related to that. Seems like odd behav开发者_运维问答ior, or I'm just missing something not-so-obvious.
I'm using Firefox 3.16 on Ubuntu, but this was also verified with Firefox 4.0 on OSX and Firefox 3.16 on Windows.
Any ideas?
This is due to image prefetch (or more precisely the image cache) in Firefox not dealing well with non-2xx return codes.
In particular, for 302 the issue is https://bugzilla.mozilla.org/show_bug.cgi?id=552605 and for 404 the issue is https://bugzilla.mozilla.org/show_bug.cgi?id=648568
精彩评论