Ads 468x60px

Monday, August 1, 2011

How to Compress Web Page

So Opera Mini is the fastest browser and also saves money. Why? They say it is their web compression technology. I don't know about theirs. But I want to share some info about it.

So first let's start by knowing what is compression. Compression technology reduces amount of data by assigning repeating sequences a same value. For example, in 'UC browser is the best browser', there are 'b' 3 times, 'r' 4 times, 'o' 2 times, 'w' 2 times etc. Compressing it can reduce the bytes a lot. While the pictures like .jpg, .gif etc are already compressed and will not benefit from more compression, the text pages can be much more compressed. A page can be compressed upto 90% depending on its content. You can try writing a text page and see how small it becomes after compressing. As HTMl pages are also plain text pages, they can also be compressed resulting huge compression.

The technology

There are two compression methods followed. Gzip and Deflate. Gzip was developed by GNU and gives better performance. The compression is a server side technology. It depends on if your browser can uncompress the page and display. If yoour browser can handle compressed pages, it sends a header Accept-Encoding: gzip, deflate: which we often find while translating UCWEB. Then if the server can compress the pages, it sends the compressed page and sends a header that the page is compressed. The browser then displays the page. If server cannot compress, it ignores the Accept-Encoding header and simply sends the normal pages.

So what is the interaction between server and browser?

In uncompressed pages

Browser sends the request to the server for a web page.

Browser: Hey, I have an address. Do you have it?

Server: Let me check,. Yes, found it. Here is it.

Browser: How much? 100kb? Oh, Downloading...

Then browser displays the page.

In compressed pages

Browser sends the request to the server for a web page.

Browser: Hey, I have an address. Do you have it? Compress it if you can.

Server: Let me check,. Yes, found it. It is 100kb. But I'll compress it.

Browser: How much? 10kb? Wow! Downloading...

Then browser displays the page.

So it overally improves performance by reducing page loading time. But as it is a server side feature, we really can't do anything

No comments:

Post a Comment