Reputation: 11
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
Reputation: 18773
To quote the PHP manual for ob_start:
Output buffers are stackable, that is, you may call
ob_start()
while anotherob_start()
is active. Just make sure that you callob_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