Generated PDFs over HTTPS with Internet Explorer


One of the applications I’ve been working on generates PDF files which the customer can download. I’m using the FPDF and FPDI libraries to import PDFs and create copies with generated contents. This has been really easy to code, and it’s been working flawlessly in both Firefox and Safari. When we started testing under Internet Explorer thing started breaking. The problem was that IE would not let the user download the file. The only feedback we got was error messages like “The file is currently unavailable or cannot be found. Please try again later.” and “The file could not be stored in cache”. After spending some time debugging I found out that IE has problems with file downloads over HTTPS. Google pointed me to this post. The guy in that post spent six hours figuring it out, and he probably saved me six hours as well. The magic required to satisfy Internet Explorers needs:

1
2
header('Cache-Control: maxage=3600');
header('Pragma: public');

Spread the message so others can spare some time!

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google
  • description
  • Live
  • Slashdot
  1. #1 by Markus - October 31st, 2007 at 13:08

    Thank you! :-)

  2. #2 by tyler - November 7th, 2007 at 21:44

    you’re awesome.

  3. #3 by Roshan - November 16th, 2007 at 08:10

    Thank You :)

  4. #4 by eirikhoem - November 16th, 2007 at 08:16

    I’m just glad to spread the word :)

  5. #5 by Jerronimo - December 4th, 2007 at 18:02

    I love you man! You’re my god!

  6. #6 by Patrick - December 31st, 2007 at 22:34

    Awesome! I love M$ products! They’re so…. in need of repair ;)

  7. #7 by Brad Cupit - January 19th, 2008 at 17:52

    Oh man, you just saved me sooo much time! Thanks for the awesome post!

  8. #8 by Oz - February 27th, 2008 at 15:12

    Thank you!

  9. #9 by Dave Lewicki - March 13th, 2008 at 08:10

    Worked like a charm. THANKS!!!!!

  10. #10 by patricia - June 11th, 2008 at 16:25

    hi, I have the same problem but with java struts,and the code is that:
    response.setContentType(“application/pdf”);
    response.setHeader(“Content-Disposition”, “attachment;Cache;filename=\”" + ruta + “\”");

    Can you help me?

  11. #11 by staryosel - August 26th, 2008 at 08:59

    Awesome! MSIE almost ruined my day but you saved it ;-)

  12. #12 by Figuss - August 26th, 2008 at 08:59

    You are my hero of the day man!
    Thank you very much for this tip. You save me a lot of precious time!!!

    …I just dream of the day when everybody will surf on the net without IE….
    What a relieve for us, simple webmasters!

  13. #13 by admin - August 26th, 2008 at 09:27

    @Figuss: The day MSIE cumbles would be a good one, but I think 8.0 is fairly interesting and I look forward to giving it a spin.

    @patricia: You should be able to push the headers in the same way as you have content disposition up there, just add the two fields in the post.

    Everyone else: Just glad to spread the word :)

  14. #14 by Are - October 22nd, 2008 at 21:30

    PHP solution: Insert this line before session_start();

    session_cache_limiter(‘private’);

(will not be published)