MVC4 bundling GZIP and headers

Matija Grcic picture Matija Grcic · Aug 27, 2012 · Viewed 9.2k times · Source

I'm testing my site with Google PageSpeed and YSlow and the bundles that i've created with MVC4 bundles aren't getting

Gzipped (Compressing resources with gzip or deflate can reduce the number of bytes sent over the network) and there is no

Vary: Accept-Encoding header (Instructs proxy servers to cache two versions of the resource: one compressed, and one uncompressed. This helps avoid issues with public proxies that do not detect the presence of a Content-Encoding header properly.)

And also how can i add encoding header for the whole scripts folder on the ISS. I know there is HTTP Response Headers, then Add Custom HTTP Response Header,

enter image description here

but will this work on the whole scripts folders and subfolders and what to put in the Name and Value fields.

How can this be solved.

Regards.

Answer

pranav rastogi picture pranav rastogi · Aug 30, 2012

make sure you set the following in system.webserver section of your web.config

<urlCompression doDynamicCompression="true"
                    doStaticCompression="true" dynamicCompressionBeforeCache="true" />
    <staticContent>
      <clientCache cacheControlMode="UseMaxAge"
                   cacheControlMaxAge="365.00:00:00" cacheControlCustom="public" />
    </staticContent>