MyBB Community Forums

Full Version: how to do Gzip Css files using ob_start ?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4
I've found on google the following code to compress gzip. Do anyone tell me, Can I set manual values for it, or it is default (copy paste thing)?
<?php
ob_start ("ob_gzhandler");
header("Content-type: text/css; charset: UTF-8");
header("Cache-Control: must-revalidate");
$offset = 60 * 60 ;
$ExpStr = "Expires: " .
gmdate("D, d M Y H:i:s",
time() + $offset) . " GMT";
header($ExpStr);
?>


You don't want that. If your webserver is worth anything, the webserver will do the gzip for you. For Apache, you can control what should be gzipped and what not with .htaccess. That's the preferable solution as it works for everything.

The gzip option in MyBB, and doing gzip with PHP, is the inferior solution.
Then What if I want to gzip global.css?
By putting something like this in your .htaccess (requires mod_deflate)

AddOutputFilterByType DEFLATE text/html text/plain text/xml text/x-js text/css application/javascript
Just that code or have to add something to global.css too? and what is "mod_deflate" ?
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/x-js text/css application/javascript
Just add that code to your .htaccess. Mod_deflate is an apache module used to gzip static files.
How would we know our server allows Mod-deflate?
You can ask your host or check your php info (in the ACP) to see if mod_deflate is enabled.
Php Version 5.2.17
Does it supports?
What you can do is add the code, then go to the following page and run the test: http://www.whatsmyip.org/http_compression/
Pages: 1 2 3 4