Can a compressed response be sent back to client even though the response from the backend is not?

Hi,

We have a requirement to send compressed response back to client. But the service provider doesn't provide compressed data to Apigee.

I tried setting 
<Property name="compression.algorithm">gzip</Property>

under HTTPProxyConnection but the response came back with the header "Transfer-Encoding = chunked"

Thanks in advance!

Solved Solved
0 4 206
1 ACCEPTED SOLUTION

You can tell Apigee to compress the response before sending it to the client.

To do so, set the Content-Encoding header in the response message, in the response flow. You can do that with an AssignMessage policy attached in the appropriate place:

<AssignMessage name="AM-Set-Compress-Response">
    <Set>
        <Headers>
            <Header name="Content-Encoding">gzip</Header>
        </Headers>
    </Set>
</AssignMessage>

Apigee will then magically compress the response. 

View solution in original post

4 REPLIES 4

You can tell Apigee to compress the response before sending it to the client.

To do so, set the Content-Encoding header in the response message, in the response flow. You can do that with an AssignMessage policy attached in the appropriate place:

<AssignMessage name="AM-Set-Compress-Response">
    <Set>
        <Headers>
            <Header name="Content-Encoding">gzip</Header>
        </Headers>
    </Set>
</AssignMessage>

Apigee will then magically compress the response. 

Thank you Dino! I'll try this out and let you know. Thanks for the quick response.

Since our proxy is common to multiple APIs, we came up with an alternate solution instead of adding the 'Assign Message' policy. We have a javascriptCallout where we add custom functions for those APIs that need additional processing. There, we set this response header for the API that needs a gzip response.

"Content-Encoding"=gzip

 

Nice! Glad it's working well for you.