Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Redirect in Internet Explorer 11 to a PDF leads to multiple requests

I 301-redirect a link to track a click.

http://myurl.tld/redirect.php?target=http%3A%2F%2Ftarget.tld%2Ffile.pdf

I track the amount of calls and some other stats on redirect.php. It works well unless I redirect to a pdf file in Internet Explorer (I tested v11, might affect other versions).
In this case, redirect.php tracks dozens of clicks within a few seconds made by the same user.
Using fiddler I found out that the pdf is returned in chunks (HTTP status code 206 Partial Content) which means several requests are made instead of a single one.
Normally, you would expect the browser to make the subsequent calls to http://target.tld/file.pdf when target.tld delivers the pdf in chunks and this is exactly what most browsers do.
However, Internet Explorer decides to request http://myurl.tld/redirect.php?target=http%3A%2F%2Ftarget.tld%2Ffile.pdf again and again and again instead of requesting the target site.

Now my questions:
How can I tell IE not to call myurl.tld but instead target.tld?
Can I manipulate the headers in the 301-redirect, so that IE knows to request the file from target.tld?

like image 676
Horen Avatar asked Apr 30 '15 11:04

Horen


1 Answers

It looks like this might have been a bug fix/workaround to a (perceived) bug in IE 9 - which apparently was too agressive in remembering 301 redirects. https://answers.microsoft.com/en-us/ie/forum/ie9-windows_7/possible-bug-in-ie-with-http-code-301-permanent/33cd03f0-8c82-e011-9b4b-68b599b31bf5

Try using HTTP 308 instead of 301 for IE 11 and see if that helps your problem.

like image 197
Kevin Keane Avatar answered Nov 02 '22 23:11

Kevin Keane