Our application uses Service Fabric as its backbone and our microservices are Service Fabric Services. After running some auditing using Lighthouse on the front-end, I saw that the recommendation to enable text based compression
was listed and began investigating how I can add gzip
to some of my responses.
For our Node server, I simply added the compression
middleware and used it.
For other services, I went inside of the Web.config
and added the following:
<urlCompression doStaticCompression="true" doDynamicCompression="true"/>
<httpCompression>
<dynamicTypes>
<clear />
<add enabled="true" mimeType="application/json"/>
</dynamicTypes>
<staticTypes>
<clear />
<add enabled="true" mimeType="application/json"/>
</staticTypes>
</httpCompression>
Upon reloading my web app, I did notice that the responses were now coming in compressed, but I do not want to necessarily compress all responses.
When I setup any of my endpoints, I follow the following format:
[HttpGet]
[Route("{customer}/items")]
[Authorize]
public Task<ItemsModel> Get()
{
return _itemsService.GetAsync();
}
Is there a way to enable compression on a per-endpoint basis instead of per-service?