PHP server timeout on script

I have a function for a wordpress plugin I’m developing that takes a lot of time.
It connects to the TMDb (movies database) and retrieves one by one all movies by id (from 0 to 8000) and creates a XML document that is saved on the local server.
Of course it takes a bunch of time, and PHP says “504 Gateway Time-out The server didn’t respond in time.”

What can I do???? any sugestions!!!

Related posts

Leave a Reply

3 comments

  1. Assuming a one-time execution and it’s bombing on you, you can set_time_limit to 0 and allow it to execute.

    <?php
      set_time_limit(0); // impose no limit
    ?>
    

    However, I would make sure this is not in production and it will only be ran when you want it to (otherwise this will place (and continue to place) a large load on the server).

  2. I think this is not related to script timeout.

    504- Gateway Timeout problem is entirely due to slow IP communication between back-end computers, possibly including the Web server.

    Fix:
    Either use proxies or increase your cache size(search for “cache” in your php.ini and play with it) limit.

    Dot