We have a custom REST API that doesn't seem to support gzip compression.
curl https://mobileteamdeploycommunity.force.com/taroworks/services/data/v33.0/ -H 'Authorization: Bearer xxxxxxxxxxxxxxxxxx' -H 'Accept-Encoding: gzip' -v
Which uses the Salesforce API seems to work fine and compresses that data. But
curl https://mobileteamdeploycommunity.force.com/taroworks/services/apexrest/performance/ -H 'Authorization: Bearer xxxxxxxxxx' -H 'Accept-Encoding: gzip' -v &> performance_with_gzip
Which uses our custom REST API doesn't compress and we get the JSON result uncompressed.
Is there a way to make compression work in the second case?
Best Answer
Created a simple test with the following code:
Ran the curl command
Where xxxxxx is the token (see resources on how to get it) and the result headers were: < HTTP/1.1 200 OK < Date: Thu, 16 Apr 2015 21:23:41 GMT < Set-Cookie: BrowserId=vOR1P_eXQxSIXNSlB05oxA;Path=/; Domain=.salesforce.com;Expires=Mon, 15-Jun-2015 21:23:41 GMT < Expires: Thu, 01 Jan 1970 00:00:00 GMT < Content-Type: application/json;charset=UTF-8 < Content-Encoding: gzip < Transfer-Encoding: chunked
and the content was indeed gzip encoded.
So Salesforce does indeed gzip compress custom REST APIs and it looks like the issue is on our side.
Resources:
http://www.oyecode.com/2014/07/try-any-salesforce-api-quickly-with.html http://www.oyecode.com/2014/08/start-building-your-own-rest-api-in.html https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_rest_code_sample_basic.htm