Reputation: 1237
I had a project that built on the latest version of servicestack 4. And it seems the response will always not including content-coding:gzip whatever I tried. I've already enabled the dynamic compression on the IIS. Don't know what else to do.
Do I need to add something to my coding? I thought it will automatically use compression if supported, NO?
Really need someone to point a direction
Thanks!!
Upvotes: 1
Views: 405
Reputation: 143359
If you just want to add a header you can always add a GZip ContentEncoding Response Header with a Response Filter, e.g:
GlobalRequestFilters.Add((req, res, dto) =>
res.AddHeader(HttpHeaders.ContentEncoding, CompressionTypes.GZip));
But ServiceStack only compresses cached responses itself i.e. when using ToOptimizedResult()
API's or returning a responses in a CompressedResult
, e.g:
public object Get(CachedOrders request)
{
var cacheKey = "unique_key_for_this_request";
return base.Request.ToOptimizedResultUsingCache(base.Cache,cacheKey,()=>
{
//Delegate is executed if item doesn't exist in cache
//Any response DTO returned here will be cached automatically
});
}
Upvotes: 1