Multiple redirects using IIS URLRedirect in FireFox when JavaScript is called
The issue I have only happens in the later additions of Firefox. I've checked the usual browsers in fiddler and they are behaving themselves
The story so far..... I have a website that has moved to a new hosting provider. The website content (images, audio etc...) used to be available on a content share using virtual directory within IIS. References to the content in HTML was done via relative paths e.g. "/images/pic.gif".
As part of the migration of the site, the content was then moved onto another URL as we didn't want to host the content on the same servers that the web code is on. (There are various reason for this but they don't affect this issue). So that we didn't have to re-point all the existing references to the content (images, audio) we used IIS URL Redirect ( http://learn.iis.net/page.aspx/460/using-the-url-rewrite-module) and set the following in web.config for the app.
<rewrite>
<rules>
<rule name="Images">
<match url="^/?images/(.*)$" />
<action type="Redirect" url="http://data.xxxx.com/images/{R:1}?ref=1" />
</rule>
</rules>
</rewrite>
The redirects work fine as the image references are prefixed with data.xxxx.com and the images display on the site fine. If we add advertising to the site by using JavaScript such as...
<script language="javascript">
if (window.adgroupid == undefined) {
window.adgroupid = Math.round(Math.random() * 1000);
}
document.write('<scr' + 'ipt language="javascript1.1" src="http://xxx.xxx.xxx/addyn/3.0/981/2185858/0/225/ADTECH;loc=100;target=_blank;key=key1+key2+key3+key4;grp=' + window.adgroupid + ';misc=' + new Date().getTime() + '"></scri' + 'pt>');
</script>
...it makes the the re开发者_运维知识库direct happen twice.
This only happens in Firefox
If I move the javascript to below the image calls then the issue does not happen.
I've tried using defer="defer" in the javascript tag, but the advertising then doesn't display on the page.
I've checked various resources and can't see why it's happening, we're not changing any code apart from the position of the javascript within the page.
I need to reduce the number of calls we're making to the content servers as we are being charged on a per call basis, so any surplus calls we make is hitting us financially.
Thanks for you help
The issue you're seeing is that the image cache in Firefox doesn't really handle redirects well (and presumably you're preventing HTTP-level caching). As a result the image prefetch that kicks off while waiting on the script and the actual image load both end up hitting the network.
See https://bugzilla.mozilla.org/show_bug.cgi?id=552605
精彩评论