Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Web Coding › How To: Speed up your website by using gzip compression
New Posts  All Forums:Forum Nav:

How To: Speed up your website by using gzip compression

post #1 of 7
Thread Starter 
Most unix based web servers running apache will have the ability to compress web content before sending it to the users browser. By using gzip compression you can compress your web content which will decrease page load times, and help users on slower connections have faster page loads, which will help increase site traffic because users will not become frustrated with having to wait for the content to load.

In this guide we will just give a very basic "How To".

To enable compression on your site is very easy however for each page you will need to make this change.

1. First rename your index.html(edit accordingly to suite your needs) to index.php


2. Once this is complete add the following code to the very first line of code on your page.
Quote:
<?php if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) ob_start("ob_gzhandler"); else ob_start(); ?>
Repeat these steps for every page you wish to compress and that is it! The process is easy however you will need to determine if your web server supports gzip compression by contacting your web host or checking to see if it is installed/enabled.

Example:

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

<h1>Here's an example page</h1>


</body>
</html>
To check page compression to be sure it is working use the following link.
http://www.gidnetwork.com/tools/gzip-test.php

Enjoy!
Desktop
(13 items)
 
  
CPUMotherboardGraphicsRAM
Q9550 EVGA 780SLi EVGA GTX285SSC 4GB OCZ Reaper HPC Edition 
Hard DriveOptical DriveOSPower
150GB Velociraptor x2 - RAID0 2 - Samsung Write Master's Window 7 64-bit 750 Watt OCZ 60 AMPs on +12v 
CaseMouse
LIAN LI PC-V2110B Black Logitech G3 
  hide details  
Reply
Desktop
(13 items)
 
  
CPUMotherboardGraphicsRAM
Q9550 EVGA 780SLi EVGA GTX285SSC 4GB OCZ Reaper HPC Edition 
Hard DriveOptical DriveOSPower
150GB Velociraptor x2 - RAID0 2 - Samsung Write Master's Window 7 64-bit 750 Watt OCZ 60 AMPs on +12v 
CaseMouse
LIAN LI PC-V2110B Black Logitech G3 
  hide details  
Reply
post #2 of 7
has anyone tried this, did it work
post #3 of 7
Quote:
Originally Posted by kc-tr View Post
1. First rename your index.html(edit accordingly to suite your needs) to index.php
do we have to change the name to .php, page doesnt load when i do
post #4 of 7
Thread Starter 
sorry for the delay, what kind of sever are you running? Also do you have php installed? more info about your setup would be great and helpful
Desktop
(13 items)
 
  
CPUMotherboardGraphicsRAM
Q9550 EVGA 780SLi EVGA GTX285SSC 4GB OCZ Reaper HPC Edition 
Hard DriveOptical DriveOSPower
150GB Velociraptor x2 - RAID0 2 - Samsung Write Master's Window 7 64-bit 750 Watt OCZ 60 AMPs on +12v 
CaseMouse
LIAN LI PC-V2110B Black Logitech G3 
  hide details  
Reply
Desktop
(13 items)
 
  
CPUMotherboardGraphicsRAM
Q9550 EVGA 780SLi EVGA GTX285SSC 4GB OCZ Reaper HPC Edition 
Hard DriveOptical DriveOSPower
150GB Velociraptor x2 - RAID0 2 - Samsung Write Master's Window 7 64-bit 750 Watt OCZ 60 AMPs on +12v 
CaseMouse
LIAN LI PC-V2110B Black Logitech G3 
  hide details  
Reply
post #5 of 7
hi, i use an ecommerce provider www.prostores.com
when i entered my site, this is what i got..

Response Headers

statusHTTP/1.1 200 OK
dateMon, 02 Jul 2007
23:46:59 GMT
serverApache
last-modifiedSun, 01 Jul 2007
17:07:54 GMT
etag"182171a-707c-4
687df6a"
accept-rangesbytes
content-length28796
connectionclose
content-typetext/html
post #6 of 7
Just FYI, if you're running a forum such as vbulletin, phpbb2, or invision, there is an option in the admin panel to enable gzip automatically (but once again your server must support it).
über pwnage v2
(15 items)
 
  
CPUMotherboardGraphicsRAM
i7 2600K 4.4GHz @ 1.36v Asus P8Z68-V LX EVGA GTX 970 SuperClocked ACX2.0 4GB G.SKILL Ripjaws X 2x8GB DDR3 @ 1648MHz 
Hard DriveOptical DriveCoolingOS
840EVO 250GB / 3TB+2TB+320GB Bar / 750GB Cav Blk Samsung DVDRW Hyper 212+ Windows 10 Pro x64 
MonitorKeyboardPowerCase
U2412M + X191W Azio MGK1 Corsair RM650X Centurion 5 with acoustic foam 
MouseMouse PadAudio
MX518 SteelSeries Xonar DG + Koss PortaPro + Logitech X-540 + Bey... 
  hide details  
Reply
über pwnage v2
(15 items)
 
  
CPUMotherboardGraphicsRAM
i7 2600K 4.4GHz @ 1.36v Asus P8Z68-V LX EVGA GTX 970 SuperClocked ACX2.0 4GB G.SKILL Ripjaws X 2x8GB DDR3 @ 1648MHz 
Hard DriveOptical DriveCoolingOS
840EVO 250GB / 3TB+2TB+320GB Bar / 750GB Cav Blk Samsung DVDRW Hyper 212+ Windows 10 Pro x64 
MonitorKeyboardPowerCase
U2412M + X191W Azio MGK1 Corsair RM650X Centurion 5 with acoustic foam 
MouseMouse PadAudio
MX518 SteelSeries Xonar DG + Koss PortaPro + Logitech X-540 + Bey... 
  hide details  
Reply
post #7 of 7
Thread Starter 
it should be enabled, can you create a new file called phpinfo.php with the following code in it, then PM me the link to it.

This will create an output like this Click Here

This is what you are looking for
Quote:
HTTP_ACCEPT_ENCODING gzip,deflate
Quote:
<?php
phpinfo();
?>
Quote:
Originally Posted by Boris4ka View Post
Just FYI, if you're running a forum such as vbulletin, phpbb2, or invision, there is an option in the admin panel to enable gzip automatically (but once again your server must support it).
Exactly. Just dont set the compression level too high, most hosting providers limit resource usage quite a bit so they can cram as many accounts on to one server as they can, and if you start hitting those limits you will have issues with your site.
Desktop
(13 items)
 
  
CPUMotherboardGraphicsRAM
Q9550 EVGA 780SLi EVGA GTX285SSC 4GB OCZ Reaper HPC Edition 
Hard DriveOptical DriveOSPower
150GB Velociraptor x2 - RAID0 2 - Samsung Write Master's Window 7 64-bit 750 Watt OCZ 60 AMPs on +12v 
CaseMouse
LIAN LI PC-V2110B Black Logitech G3 
  hide details  
Reply
Desktop
(13 items)
 
  
CPUMotherboardGraphicsRAM
Q9550 EVGA 780SLi EVGA GTX285SSC 4GB OCZ Reaper HPC Edition 
Hard DriveOptical DriveOSPower
150GB Velociraptor x2 - RAID0 2 - Samsung Write Master's Window 7 64-bit 750 Watt OCZ 60 AMPs on +12v 
CaseMouse
LIAN LI PC-V2110B Black Logitech G3 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Web Coding
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Web Coding › How To: Speed up your website by using gzip compression