How to implement GZip compression in ASP.NET?

后端 未结 9 878
后悔当初
后悔当初 2020-11-27 10:21

I am trying to implement GZip compression for my asp.net page (including my CSS and JS files). I tried the following code, but it only compresses my .aspx page (found it fro

9条回答
  •  眼角桃花
    2020-11-27 10:50

    Add .aspx extension to .css or .js file. Use <%@ Page ContentType="text/css" %> or javascript within the file to serve it with correct MIME type. & use URL Rewrite to hide this from the user agent browsers. The content-encoding response header is appended gzip to convey that gzip is the method used to perform compression. Vary response header's set to Accept-Encoding so all caches know which page (compressed or uncompressed) should be served depends on request's Accept-Encoding header. I've elaborated on this at https://stackoverflow.com/a/14509007/1624169

提交回复
热议问题