Please explain purpose of GZIP

I support a C# .NET website which prepares the request thusly:

        public GzipWebRequest(WebRequest wrappedRequest, bool compressRequest, bool acceptCompressedResponse)
        {
            this.wr = wrappedRequest;
            this.gzipRequest = compressRequest;
            if(this.gzipRequest)
                wr.Headers["Content-Encoding"] = GZIP;
            if(acceptCompressedResponse)
                wr.Headers["Accept-Encoding"] = GZIP;
        }

Please explain what GZIP is doing.

Thanks
newbiewebSr. Software EngineerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Big MontyWeb Ninja at largeCommented:
it's used for file compression on a website - https://en.wikipedia.org/wiki/Gzip
0
Dave BaldwinFixer of ProblemsCommented:
All your code is doing is putting the 'GZIP' text in the appropriate headers.  The actual use of gzip is negotiated between the browser and the server.  The server calculates whether it would take more time to gzip and send it or just send it plain.

Here are the request and response headers when connecting to my web site.
http://www.dibsplace.com/

GET / HTTP/1.1
Host: www.dibsplace.com
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:52.0) Gecko/20100101 Firefox/52.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: http://www.dibsplace.com/webdev/ndx02.html
Cookie: mailviewsplitterv=165; mailviewsplitter=575; prefsviewsplitter=195; folderviewsplitter=300; identviewsplitter=300
Connection: keep-alive
Upgrade-Insecure-Requests: 1
Pragma: no-cache
Cache-Control: no-cache

HTTP/1.1 200 OK
Date: Thu, 09 Mar 2017 21:47:57 GMT
Server: Apache/2.4.7
X-Frame-Options: SAMEORIGIN
Last-Modified: Thu, 17 Mar 2016 21:19:08 GMT
Etag: "1973-52e452e4d6b00-gzip"
Accept-Ranges: bytes
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Length: 2485
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html

Open in new window

0
Nitin SontakkeDeveloperCommented:
Here is verbose version of Dave's comment.

Over Internet, client (typically, browser application) makes a request to the web server. The data transported over wire is text. Data heavy web-sites have to send / receive bulk of data between client and server.

What if this is compressed at source, transported and decompressed at target? Great! Less data to transport over wire.

But does target know that the data is compressed and needs to be decompressed before processing? Oh, so we should have some sort of protocol to inform that.

So client while making a request informs server that 'I am capable of decompressing content using this (in your case gzip) technique, should you prefer to compress it before sending'. This is being informed as part of request header.

When server sees that client is capable of decompressing, it decides if it is more efficient to compress the contents and send.

Hope it clarifies.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
newbiewebSr. Software EngineerAuthor Commented:
thanks
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.