Jump to content

Recommended Posts

Posted
But you can still use gzip compression by adding this to the top of any php file:

 

<?php ob_start("ob_gzhandler"); ?>

 

Thanks but Do this works 100% ok?

 

I read the post at http://www.helionet.org/index/index.php?showtopic=5583 but I didn't really know what are You meaning in: You should be able to get it working with some other (rather complex) .htaccess directives, though. You would need to (using mod_rewrite) pipe all requests into a single PHP file that would GZIP everything as necessary :wacko:

 

Posted
<?php ob_start("ob_gzhandler"); ?>

 

Thanks but Do this works 100% ok?

 

That was one of the options discusssed in that page you posted. I've tried it on a couple of pages of mine and then tested them and they seemed to check ok. Add that piece of code to one of your pages and take it to this test tool:

 

http://www.gidnetwork.com/tools/gzip-test.php

 

I read the post at http://www.helionet.org/index/index.php?showtopic=5583 but I didn't really know what are You meaning in: You should be able to get it working with some other (rather complex) .htaccess directives, though. You would need to (using mod_rewrite) pipe all requests into a single PHP file that would GZIP everything as necessary :wacko:

 

That was posted by djbob and I really didn't look into doing what he said although I'm sure it can be done. I would just add the code I posted to the top of the page instead.

 

This code came from the page you posted. The only difference is they have it in an if statement checking to see if the browser accepts gzip.

 

<?php
if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) ob_start("ob_gzhandler");
else
ob_start();
?>

 

Posted

I tested the codes:

<?php
if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) ob_start("ob_gzhandler");
else
ob_start();
?>

and

 

<?php ob_start("ob_gzhandler"); ?>

 

and I tested them with different Gzip compression test tools and ALL WORKED

 

But where to put the code

 <?php
if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) ob_start("ob_gzhandler");
else
ob_start();
?>

in My pages, because every website tells different places.

 

All My pages codes are like

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
    <title>My test page</title>
</head>
<body background="images/f.jpg" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
....................................................................................................
...............................................
....................................................................................................
...............................................
....................................................................................................
...............................................
</body>
</html>

so where to put the code (the Gzip code) in My pages? :wacko:

Posted
so where to put the code (the Gzip code) in My pages? :wacko:

 

ALWAYS put it at the top of your page right before the doctype (below).

 

 <?php
if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) ob_start("ob_gzhandler");
else
ob_start();
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
        <title>My test page</title>
</head>

 

You'll never see that php code in the source of the page. Just a space before the doctype. And I guess you already know that the page has to have a .php extension.

 

Posted

Can I use <?php include("mypage.php"); ?> on every top of My pages and put in mypage.php the Gzip code, so that when I want to disable Gzip on all My pages, I only modify one page (I tested it and worked but I do not know if using php include for the Gzip code can make ERRORS or server errors....) :)

Posted

As long as you don't remove mypage.php. If the include() function can't find a page it will generate an error. So if you want to disable gzip you would need to comment out the gzip code on mypage.php like this:

 

<?php

/*

if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) ob_start("ob_gzhandler");
else
ob_start();

*/

?>

 

  • 2 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...