3

I'm trying to do performance optimization for a ASP.NET web application. At the moment I have gzip the main aspx page (using the technique from How to implement GZip compression in ASP.NET?), and merged and gzip the javascript files that are included manually (using http://atashbahar.com/post/Combine-minify-compress-JavaScript-files-to-load-ASPNET-pages-faster.aspx).

But I notice that there are 2 rather large script that I think is downloaded automatically by the framework. One seems to be for handling postback (21kb), and another for handling the asp:Menu that I have (32kb). In firebug, these appear as http://localhost:51061/WebResource.axd?d=v_Vv17tAURCE6646oHs1gmtwuRnH_kz1noYhRYi4pZJ3gy5A9YfvH6xvbJzjQds1dcPcTJ5q0OMwnGYfryCxn0MPoOgKTchA4WCQfDaV-F01&t=634619019774587441 or something like it.

Is there any way to gzip these files, or better still, also merge it with the rest of my javascript files? I cannot change the ISS setting, which seems to be the suggestion from some other threads here.

Update:

Sorry, was a bit confused there between content-type and content-encoding. Anyway, your update does not tell me what to do to fix it? Anyway, this is the header for the javascript file that was successfully encoded:

HTTP/1.1 200 OK
Server: ASP.NET Development Server/10.0.0.0
Date: Fri, 09 Mar 2012 01:34:19 GMT
X-AspNet-Version: 4.0.30319
Content-Length: 12552
Content-Encoding: gzip
Cache-Control: public, max-age=2592000
Expires: Sun, 08 Apr 2012 01:34:19 GMT
Content-Type: application/x-javascript
Connection: Close

This is the header for the system's javascript that didn't get encoded:

HTTP/1.1 200 OK
Server: ASP.NET Development Server/10.0.0.0
Date: Fri, 09 Mar 2012 01:34:19 GMT
X-AspNet-Version: 4.0.30319
Cache-Control: private
Expires: Sat, 09 Mar 2013 01:34:19 GMT
Last-Modified: Wed, 11 Jan 2012 10:06:17 GMT
Content-Type: application/x-javascript
Content-Length: 21823
Connection: Close

In the request header, both have Accept-Encoding: gzip, deflate

Community
  • 1
  • 1
ananda
  • 357
  • 1
  • 2
  • 13

1 Answers1

1

Add scriptResourceHandler setting in system.web.extensions / scripting, set enableCompression to true

<configuration>
  ...
  <system.web.extensions>
    <scripting>
      <scriptResourceHandler enableCompression="true" enableCaching="true"/>
    </scripting>
  </system.web.extensions>
  ...
</configuration>

and you can rid of custom gziping, it's better let iis to do that, set urlCompression

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

Update: Content type should not be changed, it's a same content just gzipped, in browser request there should be header :

Accept-Encoding: gzip, deflate

and in the response :

Content-Encoding: gzip

And just a note, ISA Proxy server strips gzip from Accept-Encoding request header by default, so the ISA can scan the content for malicious data, maybe some other proxy / firewall software do the same thing.

Antonio Bakula
  • 20,445
  • 6
  • 75
  • 102
  • I tried this, but it doesn't work. The content type of those javascript files are still 'application/x-javascript'. Just to confirm that I'm doing this correctly: both of those are supposed to be added under element in the web.config file, yes? – ananda Mar 08 '12 at 01:23
  • please see above for reply. Thanks. – ananda Mar 09 '12 at 01:43
  • @ananda, you testing it on development server, of course that IIS gzip wont work od another web server. – Antonio Bakula Mar 09 '12 at 09:55