AFAIK, ob_start() must be immediately after the <?php and ob_end() must be immediately before the ?>
I did read about it all to the best of my understanding - but the emphasis if I recall was to flush headers?
So what with caching, GZip and ob_ start, flush, clean - One is more confused than ever.
I mean in the example below I can't cache the Header or the Footer because they contain stuff that shouldn't be cached.
But I cache the guts of it which is the most Database demanding to load all the games and data etc.
So what would you change there to make it as small as possible in size?
<?php
/**
* @package (c) 2008 - 2015 Gnu Arcade Script
* @version $Id: index_body.php Version.1.0
* @license http://www.fsf.org/ GNU lesser General Public Licence
*/
if (!defined('IN_ARCADE')) {die('Please use the front door');}
include "templates/$template/overall_header.php";
include "includes/db-global.php";
include "includes/config.php";
$cache = RayCache::getInstance(''.$template.'.index_body', null, array('path' => 'cache/gamedata/', 'prefix' => 'gnu_', 'expire' => $set['cachelife']));
$data = $cache->read(''.$template.'.index_body');
if ($data) {
echo $data;
}else{
$cache->start_caching();
echo '
'.IMG_THL.''.$maxNew.' '.$lang['latest_games'].''.IMG_THR.''.SCRST.'
<div style="padding-left: 30px;">
<div class="content-d width100 center">';
if (!empty($ads_1)) {
echo '
<div class="ads_1">'.htmlspecialchars_decode(stripslashes($ads_1)).'</div>';
}
$maxNew = intval($games_per_cat);
$stmt = $database->prepare("SELECT
ID,
name,
description,
type,
views,
thumb,
thumb_url
FROM " . GAMES_TABLE . " WHERE active='1' ORDER BY date_added DESC LIMIT $maxNew");
$stmt->execute();
$result = $stmt->fetchAll();
foreach($result as $row)
{
$row_id = intval($row['ID']);
$row_type = intval($row['type']);
$row_views = strip($row['views']);
$row_thumb = strip($row['thumb']);
$row_thumb_url = strip($row['thumb_url']);
$bodydata = htmlEsc($row['description']);
$game_name = htmlEsc($row['name']);
include "editor/editor_bodydata.php";
if($row_type == 1){
echo ' <a href=\''.U_GAME_LINK.$row_id.'\' title="<center><span class=\'TTitle\'>'.$game_name.'</span><br /><br /><img src=\''.THUMBS.''.$row_thumb.'\' '.IMG_150X110.' alt=\'\' /><br /><b>'.$lang['total_views'].' » '.$row_views.'</b></center><br />'.tooltiplimit($bodydata).'">';
}else{
echo ' <a href=\''.U_GAME_LINK.$row_id.'\' title="<center><span class=\'TTitle\'>'.$game_name.'</span><br /><br /><img src=\''.$row_thumb_url.'\' '.IMG_150X110.' alt=\'\' /><br /><b>'.$lang['total_views'].' » '.$row_views.'</b></center><br />'.tooltiplimit($bodydata).'">';
}
if($row_type == 1){
echo ' <span class="ads_1_span"> '.IMG_THUMB_BASE_A1.$row_thumb.IMG_THUMB_BASE_A_IMG.'';
}else{
echo ' <span class="ads_1_span"> '.IMG_THUMB_BASE_A2.$row_thumb_url.IMG_THUMB_BASE_A_IMG.'';
}
echo ' </span></a>';
}
echo '
</div>
</div>
'.SCRSB.''.IMG_THB.'';
// ################ Add Most Played ###################
include "most_played.php";
$cache->write(''.$template.'.index_body');
$cache->stop_caching();
echo $cache->read(''.$template.'.index_body');
}
include "templates/$template/overall_footer.php";
?>