Hi guys

I have my own tempalate engine and it work just fine
But when i try to add gzip compression to it and i run it, Firefox give me this message:
Content Encoding Error
The page you are trying to view cannot be shown because it uses an invalid or unsupported form of compression.


Code PHP:
Here is Part of my template
 
public function display($file, $id = null,$cancelCached=false)
{
   echo $this->fetch($file, $id,$cancelCached);
}
 
public function fetch($template_file, $id = null,$cancelCached=false)
{
    if (!empty($this->template_dir))
    {
        $template_file = realpath($this->template_dir) . '/' . $template_file;
    }
    else
    {
        throw new Exception("The template directory does not exist");
    }
 
    if ($this->caching == true && (!$cancelCached) && $this->isCached($template_file, $id))
    {
        $output = $this->getCache($template_file, $id);
    }
    else
    {
        $output = $this->getOutput($template_file);
        if ($this->caching == true && (!$cancelCached))
        {
            $this->addCache($output, $template_file, $id);
        }
    }
    return isset($output) ? $output : false;
}
 
private function getOutput($template_file)
{
   extract($this->variables);
   if(file_exists($template_file))
   {
      ob_start('ob_gzhandler');
      include($template_file);
      $output = ob_get_contents();
      ob_end_clean();
   }
   else
   {
      throw new Exception("The template file '$template_file' does not exist");
   }
   return !empty($output) ? $output : false;
}

And Here The Template In Action

Code PHP:
 
     $tpl=new Template(TPL_DIR);
     $tpl->setCacheDir(CACHE_DIR);
     $tpl->setCaching(true);
 
     $tpl->set('header',$tpl->fetch('header.php'));
     $tpl->set('mainContent',$tpl->fetch('home.php'));
     $tpl->set('footer',$tpl->fetch('footer.php'));  
 
     $tpl->display('layout.php',null,true);

This Is The Part I Change
Code PHP:
 
private function getOutput($template_file)
{
   extract($this->variables);
   if(file_exists($template_file))
   {
      ob_start(); //this is where i change
      include($template_file);
      $output = ob_get_contents();
      ob_end_clean();
   }
   else
   {
      throw new Exception("The template file '$template_file' does not exist");
   }
   return !empty($output) ? $output : false;
}

Hope u guys can help me..I googled around but still cant find any solution
Thanks in advance