Jump to content

Help on a php SEO-related script


radus

Recommended Posts

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

 

Something is not going well, anybody sees what ?

 

Maybe inside php.ini or Last Modified configuration ? ( I haven't changed anything for Last Modified to work )

 

Thanks.

 

 

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 :

 

<?php

header("Cache-Control: "private, must-revalidate");

$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

Hi NIKS,

 

Not working, has a problem. Maybe in php script, or apache2.21 setting.

 

I put it here maybe somebody more experienced than me, can repair script and we all have a good script to use, and faster websites.

Link to comment
Share on other sites

  • 2 weeks later...

I FIND INFO

 

----------

 

ENJOY

 

 

 

-------------

 

 

 

Static compression styles and scripts

 

With this modification, you can give the user already compressed gzip algorithm styles and scripts. The volume of data transmitted is reduced to 20. Since the compression occurs only once in the generation of files, the load on the server at the same time is missing. After generating the files taken from the cache. This is advantageous in comparison with mod_deflate, where the compression occurs every time you email.

 

With the help of. Htaccess set the correct headers. For older browsers do not support unpacking, Lying is not compressed files with the extension. Nogzip.

 

--------------

 

 

 

Modification works in version 1.4 included with CCC

 

 

 

In classes \ Tools.php replace

 

 

 

file_put_contents($compressed_js_path, $content);

chmod($compressed_js_path, 0777);

 

 

 

 

 

to

 

 

 

file_put_contents($compressed_js_path.'.nogzip', $content);

chmod($compressed_js_path.'.nogzip', 0777);

 

$c = @gzencode($content, 9, FORCE_GZIP);

if (!empty($c)) {

file_put_contents($compressed_js_path, $c);

chmod($compressed_js_path, 0777);

}

 

 

 

 

 

file_put_contents($cache_filename, $content);

chmod($cache_filename, 0777);

 

 

 

to

 

 

 

file_put_contents($cache_filename.'.nogzip', $content);

chmod($cache_filename.'.nogzip', 0777);

$c = @gzencode($content, 9, FORCE_GZIP);

if (!empty($c)) {

file_put_contents($cache_filename, $c);

chmod($cache_filename, 0777);

}

 

 

 

then

 

 

 

make file .htaccess

 

add a file with the following contents:

 

 

 

<IfModule mod_rewrite.c>

RewriteEngine On

#redirect for Konqueror and old browsers

RewriteCond %{HTTP:Accept-encoding} !gzip [OR]

RewriteCond %{HTTP_USER_AGENT} Konqueror

RewriteRule ^(.*)\.(css|js)$ $1.nogzip.$2 [QSA,L]

</IfModule>

 

<IfModule mod_headers.c>

Header append Vary User-Agent

#set Content-Encoding for css/js files

<FilesMatch .*\.(js|css)$>

Header set Content-Encoding: gzip

Header set Cache-control: private

</FilesMatch>

#reset Content-Encoding if nogzip

<FilesMatch .*\.nogzip\.(js|css)$>

Header unset Content-Encoding

</FilesMatch>

</IfModule>

 

 

 

 

 

 

 

and put

 

themes/mytheme/cache

ziping.zip

Link to comment
Share on other sites

  • 6 months later...
  • 1 month 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...