0

I am using ob_ to do some background processing

$buffer = ob_get_contents();
header("Connection: close");
ignore_user_abort(true);
ob_start();
echo $buffer;
$size=ob_get_length();
header("Content-Length: $size");
ob_end_flush();
flush();
ob_end_clean();
file_get_contents($uri.'?loadchanges=1');

the script works fine but I need to refresh the page after

  file_get_contents($uri.'?loadchanges=1');

i tried

header( "refresh:0;" );

after or before

echo $buffer;

but it is refreshing twice and I am sure I dont need it there , I need it after the background process is finished.

any help is apreciated

Marcin Orlowski
  • 72,056
  • 11
  • 123
  • 141
Benn
  • 4,840
  • 8
  • 65
  • 106
  • that looks _very_ hacky to me. could you please explain what you are trying to do? i am almost sure that there are better alternatives for what you are seeking – Alp Oct 20 '12 at 21:59
  • I am recompiling LESS/CSS files if they have been changed, and it works fine , just need the refresh after the process is done – Benn Oct 20 '12 at 22:09

1 Answers1

0

Am not sure what you want to do but using Refresh:0 would result in continues loop you need to look for a way to make sure it does not refresh more than once also calling flush or ob_flush before calling header is not a good idea ;

Try

error_reporting(E_ALL);           //<-- Add to catch posible errors
ini_set("display_errors", "on");  //<------------^


if (!isset($_GET['refreshed'])) {
    header("Refresh: 0; URL=\"samplepage.php?refreshed=ok\"");
}
Baba
  • 94,024
  • 28
  • 166
  • 217