2013-01-07 33 views
5

Tôi đã thêm tất cả tập lệnh từ trang web của mình vào gói rất lớn (khoảng 700kb). Và bây giờ tôi muốn IIS gzip nó, nhưng tôi không thể.Gói tập lệnh Mvc 4 và GZip

Tôi đã thử mọi thứ tôi đã tìm thấy ở đây và trên web nhưng không có gì hữu ích. Tệp * .js tĩnh tuổi được nén, nhưng không hoàn thành gói.

Có giải pháp nào không?

Trả lời

5

Kiểm tra dynamic compression trong IIS. Nó phải được kích hoạt cho cả IIS và trang web của bạn. Bạn cũng phải có một cấu hình hợp lệ trong applicationHost.config quá.

<httpCompression directory="%SystemDrive%\inetpub\temp\IIS Temporary Compressed Files"> 
     <scheme name="gzip" dll="%Windir%\system32\inetsrv\gzip.dll" /> 
     <dynamicTypes> 
      <add mimeType="text/*" enabled="true" /> 
      <add mimeType="message/*" enabled="true" /> 
      <add mimeType="application/x-javascript" enabled="true" /> 
      <add mimeType="application/json" enabled="true" /> 
      <add mimeType="*/*" enabled="false" /> 
     </dynamicTypes> 
     <staticTypes> 
      <add mimeType="text/*" enabled="true" /> 
      <add mimeType="message/*" enabled="true" /> 
      <add mimeType="application/x-javascript" enabled="true" /> 
      <add mimeType="application/atom+xml" enabled="true" /> 
      <add mimeType="application/xaml+xml" enabled="true" /> 
      <add mimeType="*/*" enabled="false" /> 
     </staticTypes> 
    </httpCompression> 

Lưu ý quan trọng: kiểu nội dung của Bundling phản ứng là text/javascript, vì vậy kiểm tra cấu hình của bạn cho loại này.

+0

Như một số người khác nói, hãy thử không sử dụng notepad ++ hoặc notepad nhưng appcmd.exe để chỉnh sửa tệp applicationHost lệnh đơn này đã giúp tôi chỉnh sửa tệp: appcmd.exe set config -section: system.webServer/httpCompression/+ "dynamicTypes. [mimeType = 'application/javascript', enabled = 'True']"/commit: apphost –