How to Fix IE8 Error “Unable to download X.php from yoursite.com”
Rarely do I hear the words “Internet Explorer” and “Error” mentioned in the same sentence. Alright… maybe that’s a bit of a lie. Unfortunately however, few us can control what browsers our users are using so we have to try and cater for all instances. The one I’m going to talk about today is specific to IE8 and occured when trying to force the download of a PDF to the browser in a PHP script.
The error reads as follows:
- Unable to download somefile.php from yoursite.com.
- Internet Explorer was unable to open this site. The requested site is
- either unavailable or cannot be found. Please try again later.
After looking into the problem it turned out that the problem was down to the PHP headers being sent when outputting the file, inparticular the ‘Cache-Control’ header. If this header is not being set, or is not being set correctly you can start to experience problems.
The Solution
Previously I wasn’t using the aforementioned ‘Cache-Control’ header but apparently setting it to ‘no-cache’ or ‘no-store’ will have the same negative effect. For me the answer was to set it to ‘private’ or to set it with a blank value. Like so:
- header("Cache-Control: private");
Or:
- header("Cache-Control: ");
The site in question was also being used over SSL but I’m not sure if this also played a role. Regardless, the above worked and it kept our IE8 users happy.
0 comments:
Post a Comment