Thomas Fuchs
Hi, I'm Thomas Fuchs. I'm the author of the script.aculo.us user interface JavaScript library, a member of the Prototype core team and a Ruby on Rails core alumnus. You're using my work every day, even if you're not aware of it (sounds creepy, I know!). Need JS foo? Hire me.

IE6 and the open/save download dialog

September 25th, 2005 by Thomas Fuchs, Comments Off

t’s great thing for web sites and applications to be able to send files to the user and have the browser download them, instead of just displaying them (at least, this is very, very useful in the application we are developing at the moment).

This can be easily done with sending a:


Content-Type: what/not
Content-Disposition: attachment; filename=“blah.ext”

Ruby on Rails nicely wraps this with the send_file and send_data methods.

But… Internet Explorer 6 displays a dialog to the user, asking if it should open or save the file that it just downloaded. If you choose “open”, Internet Explorer was failing me with not finding the file it just downloaded and the helper application that is calling showing nice error dialogs about that.

So, I started an investigation, and found that Internet Explorer opens the helper applications with the file from it’s cache. If you send along a Cache-Control: no-cache header, Internet Explorer deletes the file from it’s cache before the helper application can open it! Needless to say, Firefox and Safari work fine, because they don’t download files to their cache, but to the download location you set.

A quick and easy workaround is just sending a Cache-Control: private header instead, so that the file stays in the cache.

With my newly acquired powers, I’ve submitted a change to Ruby on Rails, so this shouldn’t be an issue anymore.

Post to Twitter Tweet This Post Post to Digg Digg This Post Post to Facebook Share on Facebook

Comments Off

JavaScript Rocks! Peformance ebook
Do you run a web site or web application? Do your users a favor, and grab our ebook on JavaScript performance. Profit from our knowledge gathered in over 15 years of working with the Web and JavaScript and make your sites ultra-fast and your users ultra-happy.

Comments are closed.