By default, accessing entity services will retrieve plain data from the server. The plain data might cause scalability and performance issues as your data pool becomes larger. The best way to address these issues is to apply compression when sending and requesting data. Crosslight v4+ provides an extensible filtering concept that you can use to optimize your data access performance.
Understanding RestClient Filter Concept
Crosslight 4 introduces IRestRequestFilter and IRestResponseFilter in RestClient so that you can add your custom filtering process to optimize your data. You can then add your filters to RestClient using the following code.
IRestRequestFilter.Filter will be called before executing the request and IRestResponseFilter will be called when the response is arrived. Notice that you can add more than one filter in RestClient, these filters will be applied sequentially based on insertion order, so make sure you insert the order correctly.
To create a rest filter, you need to implement IRestRequestFilter for request filter or IRestResponse for response filter. The following code shows you how to create GZip filter using Microsoft.Bcl.Expression package.
Enabling GZip Compression in Web API Controller
By default WebAPI does not perform any filter or compression, you can perform filtering or compression by configuring HttpConfiguration as follows.
These additional compressors are available in WebApi Compression package in nuget.
In addition, you can enable compression at IIS level which automatically compress both static resources and dynamic requests. It is highly recommended to combine the IIS compression and WebApi compression for best results.
To learn how the RestFilter works and see the compression filter in action, please check out the Rest Filter Sample here: http://git.intersoftpt.com/projects/CROS-SUPP/repos/rest-filter-samples/browse.