Ensure that you are using the Kestrel
server without the IIS Integration.
Place app.UseCompressedStaticFiles();
before app.UseStaticFiles();
in Startup.Configure()
.
This will ensure that you application will serve pre compressed gzipped
(filename.ext.gz)
and brotli
(filename.ext.br)
compressed files if the browser supports it.
Checkout the example for setup.
This solution is based on @neyromant from the following issue dotnet/aspnetcore#1584 (comment).