Welcome Guest, Not a member yet? Register   Sign In
Gzip in pages?

Okay, Im using this to GZIP my pages...
function acceptsGZip(){
    $accept = str_replace(" ","",
    $accept = explode(",",$accept);
    return in_array("gzip",$accept);
    function obOutputHandler($OutputHtml){
    global $EnableGZipEncoding;
    //-- Play with HTML before output
    //-- If GZIP not supported compression is pointless.
    // If headers were sent we can not signal GZIP encoding as
    // we will mess it all up so better drop it here!
    // If you disable GZip encoding to use plain output buffering we stop here too!
    if(!acceptsGZip() || headers_sent() || !$EnableGZipEncoding) return $OutputHtml;
    //-- We signal GZIP compression and dump encoded data
    return gzencode($OutputHtml);
$this->output->set_header("Content-Encoding: gzip");
It works if I manual output scripts..css..html..but if I use $this->load->view, nothing is generated...can anyone give me an example of how to GZIP content sent through $this->load->view?

I fixed everything, so cancel this

can you share your solution? I will soon need to do this as well. thanks

Well apparently, the function I was using for GZIP wasn't working, so I just used PHPs build in ob_gzhandler, so just add this at the far beginning (Before any HTML) of any view you want GZIPped
or if your doing it directly from your controllers:
Very, very, simple. I had made it difficult by trying to use my own GZIP compression functions, which apparently don't work. =\

ok, just a regular ob_start("ob_gzhandler"); then. thanks

No prob.

I don't know if i'm loosing anything here, but.. why not simply enable it on config and let CI do the job?

| Output Compression
| Enables Gzip output compression for faster page loads.  When enabled,
| the output class will test whether your server supports Gzip.
| Even if it does, however, not all browsers support compression
| so enable only if you are reasonably sure your visitors can handle it.
| VERY IMPORTANT:  If you are getting a blank page when compression is enabled it
| means you are prematurely outputting something to your browser. It could
| even be a line of whitespace at the end of one of your scripts.  For
| compression to work, nothing can be sent before the output buffer is called
| by the output class.  Do not "echo" any values with compression enabled.
$config['compress_output'] = TRUE;

this is even better. thanks!. new to CI...

I completely forgot about the built in compressor -_-'. I feel like an idiot now lol.

Theme © iAndrew 2016 - Forum software by © MyBB