Needs flush to write buffers to prevent timeouts
-
Many hosts implement timeouts on PHP scripts that don’t finish (or have any output) for a certain amount of seconds. See here for a longer writeup of the issue:
http://donotexec.com/2013/06/cloud-sites-timeout-on-cms-install/
Because of this, the Warm Cache plugin often doesn’t finish its job when it is executed. In my situation I only want it to preload the cache once every three hours. My host limits PHP scripts to 30 seconds (if no output) and with many Pages/Posts it can take four of five runs to get everything preloaded.
In warm_cache_crawl, around line 68, I added a flush call to the end of the for loop and now the plugin runs fine the first time and no longer times out after 30 seconds.
for($i = 0;$i < $cnt;$i++){ $page = (string)$xml->url[$i]->loc; echo '<br/>Busy with: '.$page; $newvalue['pages'][] = $page; $tmp = wp_remote_get($page); flush(); // prevent timeout from the loadbalancer }
- The topic ‘Needs flush to write buffers to prevent timeouts’ is closed to new replies.