API response compression
The Commerce Service API uses JSON responses. JSON responses are not natively compressed. Response compression can optimize network bandwidth usage and increase application responsiveness. The Commerce Engine supports JSON compression using GZIP, based the on Microsoft ASP.net Core 2.1., and using the Microsoft.AspNetCore.ResponseCompression package.
By default, API response compression is enabled at the fastest level, in all Commerce Engine environments (for example, CommerceAuthoring_Sc, CommerceMinions,_Sc, CommerceShops_Sc, and CommerceOps_Sc).
You can change API compression response configuration using the C:\inetpub\wwwroot\<CommerceEnvironment>\wwwroot\config.json file.
The following shows an example of the default response compression configuration:
},
"Compression": {
"Enabled": true,
"ResponseCompressionOptions": {
"EnableForHttps": true,
"MimeTypes": [
"text/plain",
"text/css",
"application/javascript",
"text/html",
"application/xml",
"text/xml",
"application/json",
"text/json",
"application/wasm" ]
},
"GzipCompressionProviderOptions": {
"Level": "Fastest"
}
}To disable response compression, for example, in the CommerceAuthoring_Sc9 environment:
-
Open the
C:\inetpub\wwwroot\CommerceAuthoring_Sc\wwwroot\config.jsonfile. -
In the
"Compression"section, set the following parameter:"Enabled":false. -
Save the file.
To change the compression level:
-
Open the
C:\inetpub\wwwroot\CommerceAuthoring_Sc\wwwroot\config.jsonfile. -
Go to the
"GzipCompressionProviderOptions"section, and set the"Level"to the desired value.NoteThe Commerce Engine supports the following ASP.net Core 2.1 standard compression levels:
Fastest,Optimal,NoCompression. The default value isFastest. -
Save the file.