Thanks for this, it's all very helpful, but as you say, it'll be down to a bit of experimentation, I'll post the results when I get a chance.<div><br></div><div>J.<br><br><div class="gmail_quote">2009/8/4 Chris Mear <span dir="ltr"><<a href="mailto:chrismear@gmail.com" target="_blank">chrismear@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
It seems to be a workaround for this issue with IE failing to download filed specified via a Content-Disposition header, when the connection is made over HTTPS:<br>
<br>
<a href="http://support.microsoft.com/?kbid=323308" target="_blank">http://support.microsoft.com/?kbid=323308</a><br>
<br>
The root of the issue seems to be that when IE downloads and then saves/launches a file, it downloads it to a temporary store first. Unfortunately, it appears to use the same store for ordinary caching and the temporary download scratch space, so if a "don't cache" regime is in effect (which it is by default on HTTPS, or because you've specified no caching in your HTTP headers), it doesn't write the file to disk (or quickly deletes it or something) and then can't find it when it tries to save (copy/move) it to the user's desired location.<br>
<br>
This incantation of headers looks like it works by using the Pragma header to allow *some kind* of disk caching in IE (i.e. it's not set to 'no-cache'), but at the same time setting a Cache-Control header that makes IE not *really* cache it -- I'm guessing just to make sure it actually hits the server and downloads new data if you revisit the URL.<br>
<br>
According to this MSDN blog post, the post-check=0 and pre-check=0 aren't strictly necessary:<br>
<br>
<a href="http://blogs.msdn.com/ieinternals/archive/2009/07/20/Using-post_2D00_check-and-pre_2D00_check-cache-directives.aspx" target="_blank">http://blogs.msdn.com/ieinternals/archive/2009/07/20/Using-post_2D00_check-and-pre_2D00_check-cache-directives.aspx</a><br>
<br>
that is, according to the specs -- who knows what the actual behaviour of the software is.<br>
<br>
A quick trawl through the MS KB turns up issues like this attached to IE 5 and IE 6, but nothing specifically to IE 7 -- however, would be best to test.<br>
<br>
There's also some other Content-Disposition--related bugs in IE, to do with things like not setting the filename properly, or miss-guessing the content type (various versions of IE actually do magic number sniffing on the file content to check the content type, apparently as a security feature to stop people disguising executables as images or whatever), which you can turn up by searching the KB for IE articles containing 'Content-Disposition'. It may be that this incantation works around some of those as well.<br>
<br>
Chris<div><div></div><div><br>
<br>
<br>
On 4 Aug 2009, at 12:35, Joel Chippindale wrote:<br>
<br>
</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div></div><div>
I've seen the following hack for setting the headers for IE in Ruby on Rails when serving CSV files all over the place (for example <a href="http://vikasnandal.blogspot.com/2008/03/how-to-export-data-to-csv-in-ruby-on.html" target="_blank">http://vikasnandal.blogspot.com/2008/03/how-to-export-data-to-csv-in-ruby-on.html</a>).<br>
<br>
However I've never seen an explanation as to why it might be needed.<br>
<br>
Can any of you knowledgeable LRUGers enlighten me as to what the problem with IE that it is meant to resolve is and if so, which versions of IE it is a problem with and finally what happens if you don't include do these IE specific headers?<br>
<br>
#this is required if you want this to work with IE<br>
if request.env['HTTP_USER_AGENT'] =~ /msie/i<br>
headers['Pragma'] = 'public'<br>
headers["Content-type"] = "text/plain"<br>
headers['Cache-Control'] = 'no-cache, must-revalidate, post-check=0, pre-check=0'<br>
headers['Content-Disposition'] = "attachment; filename=\"#{filename}\""<br>
headers['Expires'] = "0"<br>
else<br>
headers["Content-Type"] ||= 'text/csv'<br>
headers["Content-Disposition"] = "attachment; filename=\"#{filename}\""<br>
end<br>
<br>
J.<br></div></div>
_______________________________________________<br>
Chat mailing list<br>
<a href="mailto:Chat@lists.lrug.org" target="_blank">Chat@lists.lrug.org</a><br>
<a href="http://lists.lrug.org/listinfo.cgi/chat-lrug.org" target="_blank">http://lists.lrug.org/listinfo.cgi/chat-lrug.org</a><br>
</blockquote>
<br>
_______________________________________________<br>
Chat mailing list<br>
<a href="mailto:Chat@lists.lrug.org" target="_blank">Chat@lists.lrug.org</a><br>
<a href="http://lists.lrug.org/listinfo.cgi/chat-lrug.org" target="_blank">http://lists.lrug.org/listinfo.cgi/chat-lrug.org</a><br>
</blockquote></div><br></div>