Koozai > Blog > Enabling Gzip Compression

Enabling Gzip Compression

| 7 minutes to read

Enabling Gzip compression is commonly suggested by Google and many other sources as being an important step in reducing website load times. For me personally it is a mandatory step in either the website construction or the Search Engine Optimisation process. You can detect whether Gzip compression has been enabled on the server by visiting the following website GidNetwork.

Like image optimisation this is a topic unto itself and does require some coding, fortunately like most code you can copy and paste it without having to understand it!

Gzip compression will compress certain file types; HTML, CSS, and JavaScript. It will not compress images, video or music; this should be compressed using another method or tool. We discuss these in other articles.

Step 1: Identify the Server

You must identify the type of server that you are using to host your website. I use a Firefox plugin called “Server Spy” which you can download from here. Or you can visit Netcraft and enter you website URL into the top left hand search box. Depending on the outcome will dictate what method you need to implement to enable Gzip compression.

If you use a CMS you should check the help and support sections of the provider or contact them to ask whether it is possible as not all Content Management Systems will allow you to do this.

Step 2: .Htaccess File

Hopefully you have identified your server as being one of the following:

  • Linux
  • Apache
  • Sun Java

If your server is not listed above please skip to the next step. I say hopefully you have this server type because I am an advocate of Linux servers for a number of reasons, which I will explore in another article. In short it means that you can use the hassle-free .htaccess file which is great for loads of different tasks, one of which is enabling Gzip compression.

So, first thing’s first, you must check to see if you already have a .htaccess file on your server. You can do this in a number of ways; using FTP access is probably the easiest. The file will sit on the root of the domain, so in the same place as the homepage.

If you did find a .htaccess file then open it in a word editor and copy the below code under the last line in the file, save it and upload it back to the root of the domain.

If there was no .htaccess file present, load a text editor like notepad; do not use a word processor like MS Word as this will format the text. Now copy the below code into it:

# compress the files

AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/x-javascript

# removes some bugs

BrowserMatch ^Mozilla/4 gzip-only-text/html

BrowserMatch ^Mozilla/4\.0[678] no-gzip

BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

Header append Vary User-Agent

Then save the empty text file as .htaccess – it is important to note that you include the ‘dot’ at the beginning of the file and do not save it as a .txt (see image below):

save htaccess file

That is it, Gzip compression is now enabled on your server and this will improve site load times.

Step 3: Windows Server

If you have identified your hosting server as being a UNIX server please go to the next step. If it is a MS Windows server, you may not be able to enable Gzip compression at all. This will be determined by whether the server is ‘dedicated’ or ‘shared’, the difference is significant.

A dedicated server; is a server that hosts only your website, hence it is dedicated to one task or one website. This type of server will allow Gzip compression to be enabled more easily.

A shared server; will host more than one website, if you pay for your hosting through a 3rd party vendor it will most likely be a shared server. Dedicated servers are more expensive and unless you specifically purchased one or specified it as a requirement, you will likely have a shared server. These servers can have Gzip compression enabled but it will affect every website hosted on it, this will increase server processor load and as a result many hosting companies will not enable it.

In order to do this yourself you will need Administrative access to the server. If you do not then you will need to speak to whoever does have that kind of access and ask them to do it. The steps for this are as follows:

Create Compression Folder

  • Create a folder where the compressed file will be cached. You can give it any name or leave the default: “%windir%\IIS Temporary Compressed Files”.
  • Grant write permissions to IUSR_{machinename} for the folder.

Enable Compression in IIS

  • In IIS, right-click on the “Web Sites” node and click “Properties”.
  • Select the “Service” tab.
  • Check “Compress application files”. (we have seen issues where PDFs are compressed and cannot be opened)
  • Check “Compress static files”.
  • Change “Temporary directory” (if you created your own folder).
  • Set the “Maximum temporary directory size” to something that the hard drive can handle (i.e. 1024).
  • Save and close the “Web Site” Properties.

 

Create a Web Service Extension (WSE)

  • In IIS, select “Web Service Extensions”.
  • Add a new web service extension.
  • Name it “HTTP Compression”.
  • Point it to “c:\windows\system32\inetsrv\gzip.dll”.
  • Check the “Set extension status to Allowed” to enable it.

Edit IIS Metabase

  • In IIS, right-click on the server node (top level) and click “Properties”.
  • Check “Enable Direct Metabase Edit”.
  • In Notepad, open the metabase: C:\Windows\system32\inetsrv\metabase.xml
  • Search for “<IIsCompressionScheme”
  • There will be two of them, one for deflate and one for gzip.
  • In “HcScriptFileExtensions”, add aspx, asmx and any other extension that you need to the list already there. Do this for both deflate and gzip and format the format.
  • Change “HcDynamicCompressionLevel” to 9.  Do this for both deflate and gzip.
  • Restart IIS

Step 4: UNIX Server

If you are using  UNIX server you will need to follow the below steps in order to enable Gzip compression:

Obtain Software

The IHS v2.0.42.1 software can be downloaded from the IBM HTTP Server support site.  The following URL contains a link to the software for each of the supported Workplace platforms.

https://www14.software.ibm.com/webapp/download/product.jsp?s=p&id=RBAR-5LER2T&cat=&fam=&rs=&S_TACT=104AH+W42&S_CMP=&q=2.0.42.1&pf=&sb=r&sr=1&S_TACT=104AH+W42&S_CMP=&s=p

Copy software to HTTP Server

  • With the Lotus Workplace product family it supports two primary configurations: Remote and local HTTP servers.  The key configuration difference in these two implementation methods involves the need to manually copy the plugin-cfg.xml file for the remote HTTP server.  On a locally installed system this step is not necessary.
  • The HTTP server software will be downloaded in the form of a tar’ed file.  The exact format of this download will vary by platform.
  • Transfer the downloaded file to the desired location via an operating system appropriate method.
  • Once the software has been transferred it needs to be extracted to the file system.
  • On the unix environment this is done with the following command:

o   tar –xvf HTTPServer.linux.2042.tar

o   This will create a subdirectory called IHS-2.0.42 under the directory containing the tar file.

Install Software

  • The IHS software installer is a Java based install program and requires a pre-existing Java Virtual Machine to be on the system.
  • To install the software, execute the following from within the IHS-2.0.42 subdirectory:
  • java –jar setup.jar
  • The following outline the installation steps.

o   Select Language of English

o   Select Next

o   Select I accept the terms of the license agreement

o   Select Next

o   Enter desired installation directory (default: /opt/IBMIHS)

o   Select Next

o   Choose setup type of Typical

o   Select Next

o   Confirm correct features to be installed

o   HTTPServer base

o   Application Files

o   Documentation

o   Base Extensions

o   Security

o   Select Next

o   The program will install

o   Select Finish to close the installation program

Confirm IHS installation successful

  • Navigate to the IHS binary directory (default /opt/IBMIHS/bin)
  • Start the IHS server by using the following command:

o   ./apachectl start

  • Hit the host name of the HTTP server with a web browser.  It should display the IBM HTTP Server home page as shown below.

Responses

  1. Donald avatar
    Donald

    Hi Alec,
    I have a namesco (zeus) hosting webspace.
    I follow your instruction on how to create an .htaccess file and add to the website directory. I retested the website with GIDZip test as you advice but still not enabled.
    I come from Apache hosting server then decided to purchase hosting with register365 which has (without telling you) Zeus web server. I am not sure how useful is .htaccess as they are using rewrite scripts? Not an expert though. Any advices? Thanks

    1. Randy Mc Nobody avatar
      Randy Mc Nobody

      Zeus web server doesnt support .htaccess file. You should verify info before you blindly copy-past.

      1. Mike Essex avatar

        Hi Randy, thank you for providing this information, I have updated the blog post to reflect this. All blog posts do go through an internal checking process and are fact checked by the original authors however on this occasion we should have spotted the issue with Zeus so our apologies if this caused any confusion.

  2. Alec Sharratt avatar

    No problem, I am glad you found it useful.

  3. bill gillingham avatar
    bill gillingham

    For windows/iis6… I was missing my “Web Service Extension” to allow gzip.dll. I don’t remember having to use it in the past… but it solved my problem. (Maybe mine was deleted somehow…)

    Thanks (as other instructions don’t seem to mention this requirement)

  4. Sam avatar

    I think this is the most informative and instructive post I have read so far this year. If this doesn’t help you enable Gzip compression, I don’t know what will. Looking forward to seeing what you write about next Wednesday Alec!

Leave a Reply

Your email address will not be published. Required fields are marked *

Digital Ideas Monthly

Sign up now and get our free monthly email. It’s filled with our favourite pieces of the news from the industry, SEO, PPC, Social Media and more. And, don’t forget – it’s free, so why haven’t you signed up already?