Hello all Im trying to understand how ob_start and end works, currently its using a lot of disc performance due to 500 requests per second on my webserver which kinda halts the discs. So what im trying to do is to use ob_start because thats only using memory but im not sure how it works really and i would appreciate if someone could help me. $data = 'iVBORw0KGgoAAAANSUhEUgAAABwAAAASCAMAAAB/2U7WAAAABl' . 'BMVEUAAAD///+l2Z/dAAAASUlEQVR4XqWQUQoAIAxC2/0vXZDr' . 'EX4IJTRkb7lobNUStXsB0jIXIAMSsQnWlsV+wULF4Avk9fLq2r' . '8a5HSE35Q3eO2XP1A1wQkZSgETvDtKdQAAAABJRU5ErkJggg=='; $data = base64_decode($data); //ob_start(); $im = imagecreatefromstring($data); header('Content-Type: image/png'); imagepng($im); //ob_end_clean ( ); PHP:
Not sure I really understand what you are trying to ask. But if you only output one chunk of data, then output buffering may not make much difference. You'll have to benchmark to be sure. In any case, calling ob_end_clean() like that is probably not what you want, since it just throws away all the output that has been accumulated in the buffer, and nobody ever sees it. Maybe you want ob_end_flush() or ob_get_clean()? Or none at all, and let the implicit flush happen.
buffering is not the same as caching. Are you trying to cache the data to reduce processing of pages that don't change frequently? Buffering will essentially process the page the same way it normally would except it will stor ethe results until you decide to send it. This is useful when you don't want partial pages sent or need to check the entire page for somethig (eg looking for instances of a particular set of keywords to replace with links). Otherwise I really don't think it will help the situation you describe as I understand it, and may actually make it worse.