Search code examples
c#asp.net-mvcasp.net-mvc-5bundling-and-minificationiis-8.5

asp.net mvc bundles gzip compresstion not work


My Bundle Config is like this :

public class BaseBundleConfig
{
    public static void RegisterBundles(BundleCollection bundles)
    {
        bundles.Add(new ScriptBundle("~/bundles/Models").IncludeDirectory("~/Scripts/models/", "*.js", true));

        bundles.Add(new ScriptBundle("~/bundles/framework").Include(
                                            "~/Scripts/framework/frameworkmodels.js",
                                            "~/Scripts/framework/appbase.js",
                                            "~/Scripts/framework/directives/directives.js",
                                            "~/Scripts/framework/services/Services.js",
                                            "~/Scripts/framework/controllers/controllers.js",
                                            "~/Scripts/framework/filter/filters.js",
                                            "~/Scripts/app/filter/customFilters.js"
                                            ).Include("~/Scripts/app.js"));


        bundles.Add(new StyleBundle("~/Content/css").Include(
                                        "~/Content/libs/bootstrap/bootstrap.min.css",
                                        "~/Content/libs/bootstrap/bootstrap-theme.min.css",                                     
                                        "~/Content/libs/bootstrap/angular-csp.css",
                                        "~/Content/libs/bootstrap/mainStyle.css"
                                        ));

        BundleTable.EnableOptimizations = true;

    }
}

and I used bundle's inside index.cshtml like this:

......
@System.Web.Optimization.Scripts.Render("~/bundles/framework")

.....
@System.Web.Optimization.Styles.Render("~/Content/css")

after publish on IIS 8.5. bundling and minification works as expected but bundles are not compressed for both ScriptBundle and StyleBundle. response content-type always is text/javascript or text/css. why gzip compression is not working?

chrome network tab screenshot

dynamic and static content compression both are set to true in web.config

<system.webServer>

    <urlCompression doStaticCompression="true" doDynamicCompression="true" />
</system.webServer>

MVC assembly's version: System.Web.Mvc 5.2.3.0 System.Web.Optimization 1.1.0 and Dynamic Compression module is also installed on server.

new info: two screenshot, first is IIS request tracing log that show dynamic compression module doing it's job, and second one is chrome network tab response headers for that request. why Transfer-Encoding:chunked and response is not gzip :\

IIS Trace Log

chrome network tab

thanks for your ideas


Solution

  • I found the problem point, hardware firewall between clients and IIS decompress gzip data and after processing content, send it chunked to client, when i try from other clients outside of company, gzip compression work as I expected.