Jump to content

Recommended Posts

Are there any cons to using output buffering?  With my current design, I do ob_start() at the beginning of the site, then at the end if a variable (for simplicity i'll just say $no_output) == true then ob_end_flush() will not be called and no output will happen.  This is so that certain scripts such as logging in can do their thing then still header("Location: index.php").  I'm using mvc and mod_rewrite.

 

Example:

<?php
ob_start();
$router->delegate();  //for example, if the url was /auth/login the auth controller is called and the login action ran.  
//login sets no_output to true and does header("Location: index.php");
if(!$no_output){
    //If the requested page was something like contact, then $no_ouput would be false and ob_end_flush called.
    ob_end_flush();
}
?>

 

Another option I've considered is instead of site.com/controller/action, maybe doing site.com/request_type/controller/action.  Request type would be either page or process, where page can output stuff,  and process is only for things such as login which redirect when they're done and don't produce output.

 

Any thoughts?  I'm a newbie when it comes to this type of design so let me know if I'm trying to drive a station wagon through an ocean.

 

Link to comment
https://forums.phpfreaks.com/topic/127261-design-question-output-buffering/
Share on other sites

Output buffering can slow things down and use more memory.

 

 

The performance hit it will have is directly proportional to the size of the content being stored in the buffer.

 

 

 

Oh, by the way, if I remember correctly, header("Location: blah") calls are supposed to use full, not relative, URLs.

Output buffering can slow things down and use more memory.

 

 

The performance hit it will have is directly proportional to the size of the content being stored in the buffer.

 

 

 

Oh, by the way, if I remember correctly, header("Location: blah") calls are supposed to use full, not relative, URLs.

 

Yeah, they're better as full URL for corss-browser compliance.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.