0

One of my applications is rendering a huge PDF-file. After adjusting some settings at my PHP I noticed suPHP throws an error 500-page after 5 minutes of running the script. However, I don't want to disable the maximum time since it's an webserver with multiple customers on it. Now somebody told me an possible solution:

Turn off GZIP compression on the script

When script running, add additional headers so PHP knows it has to process the whole script

Flush output after rendering the PDF

However, I've never done such a thing and I really have no idea how to accomplish this. Can someone point me in the right direction?

  • 1
    does rendering a PDF here means just creating a pdf file ? or creating it and streaming it at the same time (or something like that) ? – gyaani_guy Sep 11 '15 at 13:10
  • In this case it's just streaming it in the browser without any file on the server being created. –  Sep 11 '15 at 13:33

1 Answers1

0

Basically the somebody told you to

  • render/create the pdf and instead of sending it as you are creating it, store it in a buffer.
  • Then send it to the user with the necessary headers.

For creating pdf and storing into buffer look into output buffering - ob_start() , ob_flush() functions

For sending the contents of the buffer , this answer should help.

I am not sure how/if turning off gzip compression will help, but it can be done using the ini_set methods.

Community
  • 1
  • 1
gyaani_guy
  • 3,191
  • 8
  • 43
  • 51
  • Sorry for the slow response. Some other deadlines came between. Your answer pointed me in the right way and solved the timeouts. –  Sep 25 '15 at 11:44