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_Sc9, CommerceMinions,_Sc9, CommerceShops_Sc9, and CommerceOps_Sc9).
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_Sc9\wwwroot\config.json
file. -
In the
"Compression"
section, set the following parameter:"Enabled":false
. -
Save the file.
To change the compression level:
-
Open the
C:\inetpub\wwwroot\CommerceAuthoring_Sc9\wwwroot\config.json
file. -
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.