Problem with downloading files with Internet Explorer over HTTPS

This behaviour has bitten me before. Yesterday I was asked to resolve the issue again. And as my memory is short I was again forced to search the web for a solution. The solution is simple – but also stupid.

The problem is that Internet Explorer does not handle file dowloads without caching over https very well. Or at all. According to knowledge articles on Microsofts website the problem occurs when having one or two of the http headers:

Pragma: no-cache
Cache-control: no-cache,max-age=0,must-revalidate

Previously I have have just omitted the http header “Pragma: nocache” for IE but it seems it does not always help.

So, whether you want it or not, the solution to the IE https download cache problem is to tell IE to cache the file.

if ((isset($_SERVER["HTTPS"]) && strtolower($_SERVER["HTTPS"] == "on")) &&
    preg_match("/MSIE/", $_SERVER["HTTP_USER_AGENT"])) {
	header('Pragma: cache');
} else {
	header('Pragma: no-cache');
}
Tagged with: , ,
Posted in PHP
4 comments on “Problem with downloading files with Internet Explorer over HTTPS
  1. Jo Giraerts says:

    or instead of the
    header(“Pragma: no-cache”);
    send a
    header(“Expires: 0″);

  2. This is a well-known issue in IE for many-many years. In the past I used the following code when I had to serve a file from PHP:
    if (isset($_SERVER["HTTPS"])) {
    header(“Pragma: “);
    }

  3. Manoj says:

    Thanks… its working fine

  4. klik says:

    I used to be suggested this blog via my cousin. I’m
    not positive whether or not this post is written by means
    of him as nobody else realize such precise approximately my problem.

    You are amazing! Thank you!

1 Pings/Trackbacks for "Problem with downloading files with Internet Explorer over HTTPS"
  1. [...] the DotVoid.com blog Danne shares a quick tip on forcing downloads over HTTPS to Internet Explorer (which, of course, has to be difficult about [...]

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>