I am server pushing some CSS files in an ASP.NET MVC site like this in a controller:
public ActionResult Index()
{
var cssToPush = new[]
{
"/bundle/file1.min.css",
"/bundle/file2.min.css",
};
foreach (var file in cssToPush)
{
Response.PushPromise(file);
}
return View(GetModel());
}
When I do this, I see in the Chrome network tab that the CSS files are not using GZIP compression and they're using 44KB.
When I skip server pushing, the CSS files are using GZIP compression and they are using 14KB.
My theory is that this is because the server doesn't necessarily know if the client will accept GZIP compression, so it responds with uncompressed assets. However, I figure this is super common and there must be some standard way of enabling GZIP compression with server pushed assets. I would consider manually GZIP compressing them on the file system to be non-standard and cumbersome.
Other info:
- IIS 10 on some new Windows Server instance (Windows Server 2016 or 2019, I think).
- I'm using HTTPS and confirmed "h2" (i.e., HTTP/2) in the network tab.
- I confirmed the files are being server pushed in the "Initiator" column of the network tab.