php - using of ob_start() is suboptimal (not optimized) and it fills the ram? -


using output buffer requires server store entire output of php in ram, if have large page, i'll wind using fair amount of memory - , server have wait until entire page generated before sending out, cause small delay. that's right ?

i don't want know advantage of using ob_start();. problem redirecting , error: headers sent.

so solving problem, used of ob_start(); in fist of codes. this:

<?php ob_start(); ?>  <?php        // 500 lines of code here        header(location: www.example.com/test.php); ?>  <html>        // 1000 lines of code here </html>  <?php ob_end_flush(); ?> 

now problem has been solved, want know ok ? codes optimized ? if requests rise, site not delay ?

thanks

output buffering used , wouldn't worry this. example, webpage takes ~ 64 kib, meaning 16384 of these pages fit in 1 gib ram simultaneously.

probably offtopic, if you're going send location header, need execute other code? send header , exit() immediately.


Comments