deeped
deeped

Reputation: 11

PHP I want an own cache system (output buffer)

According to GET parameters, I want to save the output HTML and save to my own cache. Next time it's called, load the cache. It sounds easy to use ob_start() and ob_get_contents() but what if the other running scripts in between use this too? It spoils the "original" output buffering, right?

How to globally save the output?

Upvotes: 1

Views: 451

Answers (1)

Flambino
Flambino

Reputation: 18773

To quote the PHP manual for ob_start:

Output buffers are stackable, that is, you may call ob_start() while another ob_start() is active. Just make sure that you call ob_end_flush() the appropriate number of times.

In other words: No, it doesn't spoil the original output buffering; buffering can be nested. You can also use ob_get_flush() instead of ob_end_flush() to "stop" buffering.

Upvotes: 2

Related Questions