Jump to content

Page Header - Performance Tweak | Please


radus

Recommended Posts

I'm new to programming, but I compilled some scripts found for faster page loading.

 

What I want is :

 

1. Deliver Pages Compressed and in batches of 3072 bytes; (Flush zlib buffer automatically when full)

 

2. Use Zlib compression.

 

3. When crawled by engines, if page not modified since last visit , to return a "304"

 

To achive, I made changes in php.ini

 

output_buffering = Off

output_handler =

zlib.output_compression = 3072

zlib.output_compression_level = 4

zlib.output_handler = On

implicit_flush = Off

 

I also modified php script of page Header Settings :

 

Something is not going well, anybody sees what ?

 

Maybe php.ini setting of Last Modified ? ( I haven't changed anything there )

 

Thanks.

 

<?php

 

$gmtoffset = 0; // on GMT

$expires = 60*60*24*30;// in seconds, equivalent of 30 days; default expires setting from .htaccess

$dstoffset = 0; // DST offset is simultaneous all over EU

$last_modified = gmdate("D, d M Y H:i:s.", getlastmod() + $gmtoffset + $dstoffset) ." GMT";

 

if(isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) && $last_modified <= strtotime($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {

header("HTTP/1.1 304 Not Modified");

exit;

}

 

header("Last-Modified: $last_modified");

 

$expires = gmdate("D, d M Y H:i:s.", getlastmod() + $gmtoffset + $dstoffset + $expires) ." GMT";

 

header("Expires: $expires"); // to introduce Response code in header

 

$charset = "UTF-8";

$mime = "text/html";

 

header("Content-Type: $mime;charset=$charset");

header("Vary: Accept-Encoding");

header("Content-Encoding: deflate, compress, gzip");

 

ini_set("zlib.output_compression", 3072);

ob_start("zlib.output_compression");

 

?>

Link to comment
Share on other sites

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...