Jump to content

Gzip html, css, js


$php_mysql$

Recommended Posts

hey all now im new to gzip got not much knowledge on it. i was testing my site in seositecheckup and according to the test im asked to compress my html, css and js files and i found this bit of coding on google

 

<?php
if(isset($_SERVER['HTTP_ACCEPT_ENCODING']) && 

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

 

i included this file on top of my pages and then it seemed to compress my my file but it seem we need to set header expire on gzip so how could i set expire on it and could someone tell me what exactly is this coding above compressing i mean is it compressing image and all type of files?

Link to comment
https://forums.phpfreaks.com/topic/245834-gzip-html-css-js/
Share on other sites

There is no reason for you to be doing this in php code.  Apache has a module (mod_deflate) that handles gzipping things on the fly.  There are probably scores of howtos and docs on this, but here's a decent one:  http://www.justinbritten.com/work/2008/12/apache-gzip-configuration/

 

You do not want to gzip images -- they already have compression in them. 

Link to comment
https://forums.phpfreaks.com/topic/245834-gzip-html-css-js/#findComment-1263081
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.