开发者

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

how to enable HTTP com开发者_如何学编程pression for a website which is already build and running currently in Production

Regards, Gourav


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


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜