Use dynamic compression to reduce bandwidth usage
When network bandwidth can be a bottleneck, you can enabling dynamic compression on the OData service.
Dynamic compression compresses dynamically generated content at the server prior to sending the content to the client browser. The client browser will then decompress the content upon reception. This results in smaller amounts of data being sent over the network which can reduce overall bandwidth usage. Using dynamic compression will result a small increase in CPU usage at the server for each processed request.
Note: Dynamic compression on the OData service is enabled in the Internet Information Services (IIS) manager.
Dynamic compression enables the IIS web-server to compress responses coming from such handlers as the ASP.net Managed Handler, ISAPI Extensions, or CGI handlers that dynamically generate responses for requests they handle.
Once the OData service is correctly set up for dynamic compression, you must include requests for compressed content when you send requests to the OData service.
You can do this by adding a line in a SendingRequest2 event handler on the DataServiceContext. See the example below.
Example
context.SendingRequest2 += (sender, args) =>
{
if (!arg.IsBatchPart)
{
// Tell the OData server that you accept compressed content. You can do this even if the server has not been set up for dynamic compression, the server will just send uncompressed content.
((HttpWebRequestMessage)args.RequestMessage).HttpWebRequest.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
}
};