Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I see lots of information about enabling http compression for server responses but what about for incoming requests. Wouldn't it make sense for the browsers to compress large form posts before sending them to the server?

Another example is a REST web service that we use. We have to send frequent PUT requests with large XML files (10+ MB) and would definitely see some bandwidth/speed benefits on both sides.

So is this a solved problem on the server side or does each web application have to handle it individually?

share|improve this question
add comment

2 Answers

up vote 8 down vote accepted

A browser requests content to be compressed by setting Accept-Encoding header as per here:

GET /index.html HTTP/1.1
Host: www.http-compression.com
Accept-Encoding: gzip
User-Agent: Firefox/1.0

This will return compressed data to the browser. To PUT data to the server compressed you must compress the request body, while leaving the header uncompressed. It's documented in mod_deflate:

The mod_deflate module also provides a filter for decompressing a gzip compressed request body. In order to activate this feature you have to insert the DEFLATE filter into the input filter chain using SetInputFilter or AddInputFilter.

...

Now if a request contains a Content-Encoding: gzip header, the body will be automatically decompressed. Few browsers have the ability to gzip request bodies. However, some special applications actually do support request compression, for instance some WebDAV clients.

And an article describing it is here:

So how do you do it? Here is a blurb, again from the mod_deflate source code: only work on main request/no subrequests. This means that the whole body of the request must be gzip compressed if we chose to use this, it is not possible to compress only the part containing the file for example in a multipart request.

share|improve this answer
2  
+1 N.B. You write you must compress the whole request, inclusive of header. However, the http headers must not be compressed. The only thing that has to be compressed (in full, as the article you quote correctly states), is the http body. –  Eugene Beresovksy Apr 8 at 6:22
    
Thanks, updated. –  Andy Apr 8 at 9:34
add comment

Not natively from any browser I know of, you'd have to find a plugin that would do it for you. You basically have to set the content-encoding HTTP header to let the server know how the request is coming in. The server, of course, needs to be able to handle that encoding.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.