tags:

views:

79

answers:

3

I have a form that is posting a pretty long string (60k) that is highly compressible. I would like to ensure that the browser encodes the form data in a zip format to reduce the network bandwidth required, however I am not sure how to do that. Can someone point me in the right direction.

A: 

You can do this, though most people compress only the response. You should read up on GZip Deflate and content-encoding.

Here's a few resources to get you started:

This post might also help.

RichardOD
A: 

You can use a Javascript compression function.

CB
+2  A: 

The short answer is: You can't, at least not in the transparent way implied by your question. While the HTTP 1.1 spec does allow for requests to be compressed, few (if any) browsers support it. It isn't something you can just turn on with something in your HTML markup.

Even if a browser could do this, the server needs to be configured to accept it. You might end up sending the compressed request, only to have the server refuse it. Then the browser will make the request again, this time without compression.

As other people have pointed out, you can compress the data yourself in Javascript, though you'll need to decompress it within your application on the server. Don't forget to handle the case where Javascript is disabled.

Steve Madsen