Jump to content

Quick question about output buffering.


jackpf

Recommended Posts

Hi all,

I've just learnt how to use output buffering, and I was wondering whether or not to use it globally on my site, in order to send headers after html.

 

I was just wondering if there's a noticeable increase in page loading times?

 

I haven't personally noticed any, but I'd like to make sure first.

 

Any help would be greatly appreciated.

 

Regards, Jack.

Link to comment
https://forums.phpfreaks.com/topic/148300-quick-question-about-output-buffering/
Share on other sites

Firstly, assuming your talking about sending location headers after html there really is no need. It makes little sense to do so as the html you output would never be seen anyway. Better to design your applications properly in the first place.

 

Output buffering does have quite a performance hit especially when used to buffer your entire output.

Well, I normally would, but my site runs entirely through one index file, which includes different files depending on the query string.

 

So this makes it difficult to send headers for individual pages.

 

In this case I would be using OB for every page. Do you know how much longer this would take to parse?

 

Thanks for your help,

Jack.

Well, I normally would, but my site runs entirely through one index file, which includes different files depending on the query string.

 

So this makes it difficult to send headers for individual pages.

 

More difficult maybe, impossible no. Its up to you.

 

Do you know how much longer this would take to parse?

 

Couldn't put a figure on it and in fact, you probably won't notice a lot of difference depending on how much is in your buffer.

Hmm....well I'd say it would be pretty much impossible without actually making an entirely new file for this one little page I want to set a cookie on.

 

The reason I have my entire site run through index.php is to reduce unnescessary files; this would kind of invalidate that.

 

Hmm....well, what's actually stored in the buffer? Is it just the html being sent to the page or the entire php script?

 

My html pages are pretty normal sized, but because I have a small amount of files, my actual php scripts are up to around 1500 lines.

 

Thanks for your help, Jack.

Hmm....well I'd say it would be pretty much impossible without actually making an entirely new file for this one little page I want to set a cookie on.

 

All my applications use one entry point (not one file though), its far from impossible if designed properly.

 

The reason I have my entire site run through index.php is to reduce unnescessary files; this would kind of invalidate that.

 

Im not sure that makes sense. Breaking your application into different files allows for much easier maintainence.

 

Hmm....well, what's actually stored in the buffer? Is it just the html being sent to the page or the entire php script?

 

The output you put in it. Its not called the output buffer for nothing :)

Hmm...well, I am only 16- not quite an "application" programmer yet; I just make my site as a pass time. So yeah, I don't really know how to go about this any other way.

 

And I find having less files more manageable... eg, if I wanted to change something, instead of search & replaceing tens of files, I can just do one.

 

And well, I have ob_start() at the very top of my index file, and I return the buffer at the very end, so basically everything.

 

And lol, yeah I know what output means, I'm just unsure as to what OB is defining as output.

 

Thanks for your help, I appreciate it.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.