-1

I want to know what does set_timeout (30) do?! I read document about this from simple pie docs

Allows you to override the maximum amount of time spent waiting for the remote feed's server to respond and send the feed back so that we can begin processing it.

I don't understand what does it work!?! does it make to fast loading of website or not?!

1 Answers1

1

This function will allow you to override the maximum amount of time that it waits for response from the server. Meaning, if the server sometimes has bad response time you can set it to wait longer for it. Instead of proceeding.

It can make it faster or slower. Depends on what you input in the parameters.

  • you mean if i set it to 30 second the feeds override start after 30 second right?! – m.javad Koushki Oct 25 '16 at 18:53
  • 1
    No, it means the feed will wait for 30 seconds to get a response from the server. If that is what you are trying to do, that is not the current function. This will only let you change how much you wait for the server. If you are trying to setTimout() like in Javascript then you have the wrong function. – Gabriel O. Nieves Oct 25 '16 at 18:57
  • Let me clarify. If you want to set the maximum wait time for the server to be 30 seconds, use this function. If you want to wait 30 seconds to actually call the function, don't use this method. – Gabriel O. Nieves Oct 25 '16 at 18:58
  • no i want to wait 30 seconds to load completlly my website then feeds start updating. – m.javad Koushki Oct 25 '16 at 19:10
  • actually i want at first my website load completlly then all rss feeds in main page start updating and i think timeout is for feeds fetch response time – m.javad Koushki Oct 25 '16 at 19:18
  • Okay, if you are using Javascript, you can use setTimeout to wait to make the callback. – Gabriel O. Nieves Oct 25 '16 at 20:02
  • no i dont use javascript i use simplepie php codes $feed = new SimplePie(); $feed->set_feed_url(''.$link1.''); $feed->enable_order_by_date(false); $feed->set_cache_location($_SERVER['DOCUMENT_ROOT'] . '/cache'); $feed->set_cache_duration($time); $feed->handle_content_type(); $feed->set_timeout(10); $feed->init(); – m.javad Koushki Oct 25 '16 at 20:04
  • Okay, so what you are doing is just setting the maximum amount to wait for the feed server. If it exceeds "10" time unit, it will go on evaluating the rest. If you want to wait for 10 seconds before initializing just use "sleep(time)". – Gabriel O. Nieves Oct 25 '16 at 20:14
  • It is a PHP function, just use "sleep()" instead of setTimeout. – Gabriel O. Nieves Oct 25 '16 at 21:39