Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I gzip my web files

Tags:

php

.htaccess

As prescribed by Yahoo!, gzip'ng files would make your websites load faster. The problem? I don't know how :p

like image 292
Teej Avatar asked Nov 17 '08 05:11

Teej


People also ask

How do I compress a web page?

On your local computer, select the files you wish to compress. On a Windows PC, right-click and select Send to > Compressed (zipped) folder. If you're using Mac OS, right-click and select Compress. You can now upload your zip file to your server using an FTP client, or cPanel File Manager.

How do I gzip a HTML file?

In your browser: In Chrome, open the Developer Tools > Network Tab (Firefox/IE will be similar). Refresh your page, and click the network line for the page itself (i.e., www.google.com ). The header “Content-encoding: gzip” means the contents were sent compressed.

How does browser gzip work?

Using gzip on the Web When a browser with gzip support sends a request, it adds “gzip” to its Accept-Encoding header. When the web server receives the request, it generates the response as normal, then checks the Accept-Encoding header to determine how to encode the response.


2 Answers

http://www.webcodingtech.com/php/gzip-compression.php

Or if you have Apache, try http://www.askapache.com/htaccess/apache-speed-compression.html

Some hosting services have an option in the control panel. It's not always possible, though, so if you're having difficulty, post back with more details about your platform.

like image 61
Mark Avatar answered Oct 05 '22 22:10

Mark


If you are running Java Tomcat then you set a few properties on your Connector ( in conf/server.xml ).

Specifically you set:

  1. compressableMimeType ( what types to compress )
  2. compression ( off | on | )
  3. noCompressionUserAgents ( if you don't want certain agents to receive gzip, list them here )

Here's the tomcat documentation which discusses this: http://tomcat.apache.org/tomcat-5.5-doc/config/http.html

like image 22
Darren Hicks Avatar answered Oct 06 '22 00:10

Darren Hicks