How do I enable gzip compression when using MVC3 on IIS7?

后端 未结 3 816
Happy的楠姐
Happy的楠姐 2020-12-02 04:47

Does anybody know how to enable gzip compression in MVC 3? I\'m using IIS7.

Google Chrome Audit\'s result:

  1. Enable gzip compression (4)
3条回答
  •  离开以前
    2020-12-02 04:58

    You can configure compression through your web.config file as follows:

    
        
    
    

    You can find documentation of this configuration element at iis.net/ConfigReference. This is the equivalent of:

    1. Opening Internet Information Services (IIS Manager)
    2. Navigating through the tree-view on the left until you reach the virtual directory you wish to modify
    3. Selecting the appropriate virtual directory so that the title of the right-hand pane becomes the name of said virtual directory.
    4. Choosing "Compression" under "IIS" in the right-hand pane
    5. Ticking both options and choosing "Apply" under "Actions" on the far right.

    Note: (As pointed out in the comments) You need to ensure that Http Dynamic Compression is installed otherwise setting doDynamicCompression="true" will not have any effect. The quickest way to do this is:

    1. Start > Type optionalfeatures (this is the quickest way to get to the "Turn Windows Features on or off" window)
    2. Navigate to Internet Information Services > World Wide Web Services > Performance Features in the "Windows Features" treeview
    3. Ensure "Dynamic Content Compression" is ticked
    4. Click "Ok" and wait whilst Windows installs the component

提交回复
热议问题