views:

130

answers:

1

I had asked a few questions regarding compressing HTTP Request headers here and here but I some how skipped the HTTP response part... I am looking for a way to reduce/compact the headers in my HTTP response...
The situation is that I am communicating a Java ME app with a remote Server and any extra baggage is causing me to shed out loads of $$...
Presuming both the client and server are under my control what solution would you'll suggest?

+2  A: 

The same general mechanisms for compressing requests apply to responses. And once again, the headers themselves are not compressible ... only the response content can be compressed in an HTTP 1.1 compliant implementation.

The way to specify that the server should compress the response is to set an "Accept-encoding" header, as described in section 14.3 of the HTTP 1.1 spec. However, you are at the mercy of the service implementation as to whether it will actually compress the response for you. If the server cannot / will not compress as you have asked, it may send a 406 Not Acceptable response. Alternatively, a crufty server-side HTTP implementation may ignore your Accept-* headers and send the response uncompressed.

Stephen C
You mean comression is not totally under our control?... the server side implementation decides it?..
Kevin Boyd
@Kevin - yup. The HTTP spec describes the way that you specify what is acceptable, but ultimately the server is free to say that it cannot / will not deliver the content in the form you want.
Stephen C