0

how to enable HTTP compression for a website which is already build and running currently in Production

Regards, Gourav

gourav
  • 1,397
  • 5
  • 20
  • 31

3 Answers3

2

in APACHE .HTACCESS (Dont know what server side are you running):

    # compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript

It does not matter if the site is running or not, it is .HTACCESS config.

for IIS: http://technet.microsoft.com/en-us/library/cc771003%28WS.10%29.aspx

FOR APACHE: http://betterexplained.com/articles/how-to-optimize-your-site-with-gzip-compression/

you should test the results with firebug

fatnjazzy
  • 6,070
  • 12
  • 57
  • 83
1

Compression is negotiated between the client and server.

The client will typically issue a request indicating that it can accept a compressed response, but doesn't have to. So you can then enable compression at the server end and your clients will receive a compressed response only if requested.

Check out the Accept HTTP header.

Brian Agnew
  • 268,207
  • 37
  • 334
  • 440
1

My favourite option is google's pagespeed mod for apache 2. It installs effortless on ubuntu, and presumable other linux distros.

You can see a quick list of all the features it has here.

  • Extended Cache
  • Puts inline CSS into external files
  • Puts inline Javascript into external files
  • Combine external CSS
  • Move external CSS inline to the html
  • Move external Javscript inline to the html
  • Collapse whitespace in html
  • Combine headers
  • Elide attributes
  • Minify Javascript
  • Move small images inline
  • Remove html comments
  • Remove unneeded quotes from html attributes

All of the above are customizable and can be enabled/disabled as required.

xzyfer
  • 13,937
  • 5
  • 35
  • 46