How do I gzip my web files

前端 未结 9 1497
抹茶落季
抹茶落季 2021-02-03 11:45

As prescribed by Yahoo!, gzip\'ng files would make your websites load faster. The problem? I don\'t know how :p

相关标签:
9条回答
  • 2021-02-03 12:26

    Jetty will look for gzip'd versions of static files, as well as it has a GzipFilter for dynamic content.

    You could probably pull the GzipFilter over into Tomcat if you wanted more control over compression than just Tomcat's connector-level compression...

    http://docs.codehaus.org/display/JETTY/GZIP+Compression

    0 讨论(0)
  • 2021-02-03 12:31

    Edit your httpd.conf file.

    Add this line to load the module:

    LoadModule deflate_module modules/mod_deflate.so
    

    Add these lines to actually compress the output:

    AddOutputFilterByType DEFLATE text/css text/html application/x-javascript application/javascript
    BrowserMatch ^Mozilla/4 gzip-only-text/html
    BrowserMatch ^Mozilla/4\.0[678] no-gzip
    BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
    
    0 讨论(0)
  • 2021-02-03 12:33

    Seeing how most answers here are almost 5 years old, here's some very current and up to date example references.

    For example server configs that enable gzip/deflate type compression for iis, lighthttpd, nginx, and even node see: https://github.com/h5bp/server-configs

    For a very good current implementation of Apache mod_deflate see https://github.com/h5bp/html5-boilerplate/blob/master/.htaccess#L156

    0 讨论(0)
提交回复
热议问题