{"id":401,"date":"2024-04-01T19:37:07","date_gmt":"2024-04-01T11:37:07","guid":{"rendered":"http:\/\/www.esufy.com\/?p=401"},"modified":"2024-04-01T19:37:07","modified_gmt":"2024-04-01T11:37:07","slug":"%e7%bd%91%e7%ab%99%e7%ac%ac%e4%b8%80%e6%ac%a1%e6%89%93%e5%bc%80%e5%a4%aa%e6%85%a2%e4%ba%86%ef%bc%8c%e6%80%8e%e4%b9%88%e5%bc%80%e5%90%afgzip%e5%8e%8b%e7%bc%a9","status":"publish","type":"post","link":"http:\/\/www.esufy.cn\/?p=401","title":{"rendered":"\u7f51\u7ad9\u7b2c\u4e00\u6b21\u6253\u5f00\u592a\u6162\u4e86\uff0c\u600e\u4e48\u5f00\u542fgzip\u538b\u7f29"},"content":{"rendered":"<div class=\"dpu8C _2kCxD \">\n<p>\u6211\u4eec\u6700\u8fd1\u505a\u7684\u4e00\u4e2a\u9879\u76ee\uff0c\u51fa\u73b0\u4e86\u7f51\u7ad9\u7b2c\u4e00\u6b21\u6253\u5f00\u975e\u5e38\u6162\u7684\u60c5\u51b5\u3002\u7a0d\u5fae\u5206\u6790\u4e00\u4e0b\uff0c\u5c31\u80fd\u770b\u51fa\u95ee\u9898\u3002\u539f\u6765\u662f\u7b2c\u4e00\u6b21\u6253\u5f00\u8981\u90a3\u4e9bjs\u3001css\u4ec0\u4e48\u7684\uff0c\u52a0\u8d77\u6765\u8981\u52a0\u8f7d\u597d\u51e0M\u3002\u7f51\u901f\u8981\u662f\u6162\u4e00\u70b9\uff0c\u6253\u5f00\u4e00\u4e2a\u9996\u9875\u90fd\u898120\u51e0\u79d2\u3002<\/p>\n<\/div>\n<div class=\"dpu8C _2kCxD \">\n<p>\u90a3\u4e48\uff0c\u8981\u600e\u4e48\u89e3\u51b3\u5462\uff1f\u4f18\u5316\u70b9\u4e4b\u4e00\u5c31\u662f\u5f00\u542fgzip\u538b\u7f29\u3002<\/p>\n<\/div>\n<div class=\"dpu8C _2kCxD \">\n<p>\u5f00\u59cb\u4e4b\u524d\uff0c\u6211\u4eec\u5148\u4e86\u89e3\u4e00\u4e0bgzip\u662f\u4ec0\u4e48\uff1f<\/p>\n<\/div>\n<div class=\"dpu8C _2kCxD \">\n<p>Gzip\u662f\u4e00\u79cd\u6570\u636e\u538b\u7f29\u7b97\u6cd5\uff0c\u901a\u8fc7\u5c06\u6587\u672c\u3001\u6837\u5f0f\u8868\u3001\u811a\u672c\u548c\u5176\u4ed6\u53ef\u538b\u7f29\u7684\u5185\u5bb9\u538b\u7f29\u6210\u66f4\u5c0f\u7684\u6587\u4ef6\uff0c\u4ece\u800c\u51cf\u5c11\u4f20\u8f93\u6570\u636e\u91cf\u3002<\/p>\n<\/div>\n<div class=\"dpu8C _2kCxD \">\n<p>\u5f53\u6d4f\u89c8\u5668\u652f\u6301Gzip\u5e76\u8bf7\u6c42\u7f51\u9875\u65f6\uff0c\u670d\u52a1\u5668\u4f1a\u5c06\u54cd\u5e94\u7684\u5185\u5bb9\u8fdb\u884c\u538b\u7f29\uff0c\u5e76\u5728\u6d4f\u89c8\u5668\u7aef\u89e3\u538b\u7f29\uff0c\u5b9e\u73b0\u6570\u636e\u4f20\u8f93\u7684\u4f18\u5316\u3002<\/p>\n<\/div>\n<div class=\"dpu8C _2kCxD \">\n<p>\u901a\u8fc7\u5f00\u542fGzip\u538b\u7f29\uff0c\u60a8\u53ef\u4ee5\u52a0\u901f\u7f51\u7ad9\u7684\u52a0\u8f7d\u901f\u5ea6\uff0c\u51cf\u5c11\u5e26\u5bbd\u4f7f\u7528\uff0c\u63d0\u5347\u7528\u6237\u4f53\u9a8c\u3002<\/p>\n<\/div>\n<div class=\"dpu8C _2kCxD \">\n<p>\u4e86\u89e3\u5b8cgzip\u662f\u4ec0\u4e48\uff0c\u6211\u4eec\u6765\u770b\u4e00\u4e0b\u600e\u4e48\u5f00\u542fgzip\u538b\u7f29\u3002<\/p>\n<\/div>\n<div class=\"dpu8C _2kCxD \">\n<p><strong>1\u3001\u901a\u8fc7nginx\u5f00\u542fgzip\u538b\u7f29<\/strong><\/p>\n<\/div>\n<div class=\"dpu8C _2kCxD \">\n<p>\u901a\u8fc7nginx\u5f00\u542fgzip\u538b\u7f29\uff0c\u662f\u4e00\u79cd\u5f88\u901a\u7528\u7684\u65b9\u6cd5\u3002<\/p>\n<\/div>\n<div class=\"dpu8C _2kCxD \">\n<p>\u6253\u5f00nginx\u7684\u914d\u7f6e\u6587\u4ef6nginx.conf\uff0c\u6dfb\u52a0gzip\u76f8\u5173\u914d\u7f6e\uff0c\u5177\u4f53\u914d\u7f6e\u5982\u4e0b\uff1a<\/p>\n<\/div>\n<div class=\"dpu8C _2kCxD \">\n<pre class=\"custom\"><code class=\"hljs\">http {\r\n    # \u5f00\u542f\u538b\u7f29\u529f\u80fd\r\n    gzip on;\r\n    # \u8bbe\u7f6e\u538b\u7f29\u7ea7\u522b\r\n    gzip_comp_level 5;\r\n    # \u8bbe\u7f6e\u538b\u7f29\u7c7b\u578b\r\n    gzip_types text\/plain text\/css application\/json application\/javascript text\/xml application\/xml application\/xml+rss text\/javascript;\r\n    # \u8bbe\u7f6e\u6700\u5c0f\u538b\u7f29\u6587\u4ef6\u5927\u5c0f\r\n    gzip_min_length 1k;\r\n    # \u8bbe\u7f6e\u538b\u7f29\u7f13\u51b2\u533a\u5927\u5c0f\r\n    gzip_buffers 4 32k;\r\n    # \u8bbe\u7f6e\u538b\u7f29\u540e\u6570\u636e\u7684\u7f13\u5b58\u65f6\u95f4\r\n    gzip_proxied any;\r\n    # \u8bbe\u7f6e\u538b\u7f29\u6bd4\u4f8b\r\n    gzip_vary on;\r\n    # \u8fc7\u6ee4\u6389IE6\u7b49\u4e0d\u652f\u6301\u538b\u7f29\u7684\u6d4f\u89c8\u5668\r\n    gzip_disable \"MSIE [1-6]\\.(?!.*SV1)\";\r\n    ...\r\n    server {\r\n        listen       80;\r\n        server_name  abc.acvy.com;\r\n        ...\r\n        location \/ {\r\n            # \u5c06\u538b\u7f29\u540e\u7684\u6570\u636e\u53d1\u9001\u7ed9\u5ba2\u6237\u7aef\r\n            gzip_static on;\r\n            # \u8f6c\u53d1\u8bf7\u6c42\u7ed9\u540e\u7aef\u670d\u52a1\u5668\r\n            proxy_pass http:\/\/backend;\r\n        }\r\n    }\r\n    ...\r\n}\r\n\r\n<\/code><\/pre>\n<\/div>\n<div class=\"dpu8C _2kCxD \">\n<ul class=\" list-paddingleft-2\">\n<li>\n<section>gzip on \u8868\u793a\u5f00\u542f\u538b\u7f29\u529f\u80fd<\/section>\n<\/li>\n<li>\n<section>gzip_comp_level 5 \u8868\u793a\u8bbe\u7f6e\u538b\u7f29\u7ea7\u522b\u4e3a 5<\/section>\n<\/li>\n<li>\n<section>gzip_types \u6307\u5b9a\u8981\u538b\u7f29\u7684\u6587\u4ef6\u7c7b\u578b<\/section>\n<\/li>\n<li>\n<section>gzip_min_length \u6307\u5b9a\u6700\u5c0f\u538b\u7f29\u6587\u4ef6\u5927\u5c0f<\/section>\n<\/li>\n<li>\n<section>gzip_buffers \u6307\u5b9a\u538b\u7f29\u7f13\u51b2\u533a\u5927\u5c0f<\/section>\n<\/li>\n<li>\n<section>gzip_proxied \u6307\u5b9a\u7f13\u5b58\u65f6\u95f4<\/section>\n<\/li>\n<li>\n<section>gzip_vary \u8868\u793a\u542f\u7528 Vary \u5934\uff0c\u7528\u4e8e\u652f\u6301\u4ee3\u7406\u7f13\u5b58<\/section>\n<\/li>\n<li>\n<section>gzip_static on \u8868\u793a\u5c06\u538b\u7f29\u540e\u7684\u6570\u636e\u53d1\u9001\u7ed9\u5ba2\u6237\u7aef<\/section>\n<\/li>\n<li>\n<section>proxy_pass \u6307\u5b9a\u540e\u7aef\u670d\u52a1\u5668\u5730\u5740<\/section>\n<section><\/section>\n<\/li>\n<\/ul>\n<\/div>\n<div class=\"dpu8C _2kCxD \">\n<section>\u4fee\u6539\u5b8c\u914d\u7f6e\uff0c\u91cd\u542f\u4e00\u4e0bnginx\u670d\u52a1\u5c31\u53ef\u4ee5\u4e86\u3002<\/section>\n<\/div>\n<div class=\"dpu8C _2kCxD \">\n<p><strong>2\u3001\u901a\u8fc7springboot\u914d\u7f6e\u6587\u4ef6\u914d\u7f6e\u5f00\u542fgzip\u538b\u7f29<\/strong><\/p>\n<\/div>\n<div class=\"dpu8C _2kCxD \">\n<p>\u56e0\u4e3a\u6211\u4eec\u662fspringboot\u7684\u9879\u76ee\uff0c\u6240\u4ee5\u6211\u4eec\u4e5f\u53ef\u4ee5\u901a\u8fc7springboot\u7684\u914d\u7f6e\u6587\u4ef6\u6765\u5f00\u542fgzip\u538b\u7f29\u3002<\/p>\n<\/div>\n<div class=\"dpu8C _2kCxD \">\n<section>\u5982\u679c\u914d\u7f6e\u6587\u4ef6\u662fapplication.yml\uff0c\u90a3\u4e48\u914d\u7f6e\u5982\u4e0b\uff1a<\/section>\n<\/div>\n<div class=\"dpu8C _2kCxD \">\n<pre class=\"custom\"><code class=\"hljs\">server:\r\n  compression:\r\n    # \u5f00\u542fGzip\u538b\u7f29\r\n    enabled: true\r\n    # \u6700\u5c0f\u538b\u7f29\u5927\u5c0f\r\n    min-response-size: 2048\r\n    # \u8981\u8fdb\u884c\u538b\u7f29\u7684\u54cd\u5e94\u7c7b\u578b\r\n    mime-types: text\/html,text\/xml,text\/plain,text\/css,text\/javascript,application\/javascript,application\/json,application\/xml\r\n<\/code><\/pre>\n<\/div>\n<div class=\"dpu8C _2kCxD \">\n<section>\u5982\u679c\u914d\u7f6e\u6587\u4ef6\u662fapplication.properties\uff0c\u90a3\u4e48\u914d\u7f6e\u5982\u4e0b\uff1a<\/section>\n<\/div>\n<div class=\"dpu8C _2kCxD \">\n<pre class=\"custom\"><code class=\"hljs\"><span class=\"bash\"># \u5f00\u542fGzip\u538b\u7f29\r\nserver.compression.enabled=true\r\n# \u6700\u5c0f\u538b\u7f29\u5927\u5c0f\r\nserver.compression.min-response-size=2048\r\n# \u8981\u8fdb\u884c\u538b\u7f29\u7684\u54cd\u5e94\u7c7b\u578b\r\nserver.compression.mime-types=text\/html,text\/xml,text\/plain,text\/css,text\/javascript,application\/javascript,application\/json,application\/xml<\/span><\/code><\/pre>\n<\/div>\n<div class=\"dpu8C _2kCxD \">\n<ul class=\" list-paddingleft-2\">\n<li>\n<section>server.compression.enabled true\u8868\u793a\u5f00\u542fGzip\u538b\u7f29<\/section>\n<\/li>\n<li>\n<section>server.compression.min-response-size \u8868\u793a\u6700\u5c0f\u538b\u7f29\u5927\u5c0f<\/section>\n<\/li>\n<li>\n<section>server.compression.mime-types \u8868\u793a\u8981\u8fdb\u884c\u538b\u7f29\u7684\u54cd\u5e94\u7c7b\u578b<\/section>\n<\/li>\n<\/ul>\n<\/div>\n<div class=\"dpu8C _2kCxD \">\n<p>\u4e0a\u9762\u7684min-response-size\u9ed8\u8ba4\u662f2048\uff0c\u4ec5\u4f1a\u538b\u7f292048\u5b57\u8282\u4ee5\u4e0a\u7684\u5185\u5bb9\uff0c\u5982\u679c\u6211\u4eec\u6309\u8fd9\u4e2a\u9ed8\u8ba4\u503c\u7684\u8bdd\uff0c\u4e5f\u53ef\u4ee5\u4e0d\u914d\u7f6e\u3002<\/p>\n<\/div>\n<div class=\"dpu8C _2kCxD \">\n<section>\u8fd8\u6709\uff0cmime-types\uff0c\u5728spring2.0+\u7684\u7248\u672c\u4e2d\uff0c\u9ed8\u8ba4\u503c\u5982\u4e0b\uff0c\u6240\u4ee5\u4e00\u822c\u6211\u4eec\u4e5f\u4e0d\u9700\u8981\u7279\u610f\u6dfb\u52a0\u8fd9\u4e2a\u914d\u7f6e\u3002<\/section>\n<\/div>\n<div class=\"dpu8C _2kCxD \">\n<pre class=\"custom\"><code class=\"hljs\"><span class=\"bash\">\/\/ org.springframework.boot.web.server.Compression#mimeTypes\r\n\/**\r\n * Comma-separated list of MIME types that should be compressed.\r\n *\/\r\nprivate String[] mimeTypes = new String[] { \"text\/html\",\r\n                        \"text\/xml\",\r\n                        \"text\/plain\",\r\n                        \"text\/css\",\r\n                        \"text\/javascript\",\r\n                        \"application\/javascript\",\r\n                        \"application\/json\",\r\n                        \"application\/xml\" };<\/span><\/code><\/pre>\n<\/div>\n<div class=\"dpu8C _2kCxD \">\n<p>\u4e5f\u5c31\u662f\u8bf4\uff0c\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u6211\u4eec\u53ea\u9700\u914d\u7f6e<\/p>\n<\/div>\n<div class=\"dpu8C _2kCxD \">\n<pre class=\"custom\"><code class=\"hljs\"><span class=\"bash\">server:\r\n  compression:\r\n    # \u5f00\u542fGzip\u538b\u7f29\r\n    enabled: true\r\n<\/span><\/code><\/pre>\n<\/div>\n<div class=\"dpu8C _2kCxD \">\n<p>\u6216\u8005<\/p>\n<\/div>\n<div class=\"dpu8C _2kCxD \">\n<pre class=\"custom\"><code class=\"hljs\"><span class=\"bash\"># \u5f00\u542fGzip\u538b\u7f29\r\nserver.compression.enabled=true<\/span><\/code><\/pre>\n<\/div>\n<div class=\"dpu8C _2kCxD \">\n<p>\u5c31\u53ef\u4ee5\u4e86\u3002<\/p>\n<\/div>\n<div class=\"dpu8C _2kCxD \">\n<p>\u4fee\u6539\u5b8c\uff0c\u6211\u4eec\u4e5f\u8981\u91cd\u542f\u4e00\u4e0b\u5e94\u7528\u670d\u52a1\u3002<\/p>\n<\/div>\n<div class=\"dpu8C _2kCxD \">\n<p><strong>3\u3001\u6d4b\u8bd5\u6548\u679c<\/strong><\/p>\n<\/div>\n<div class=\"dpu8C _2kCxD \">\n<section>\u5f00\u542fgzip\u538b\u7f29\u4e4b\u540e\uff0c\u6e05\u6389\u6d4f\u89c8\u5668\u7f13\u5b58\uff0c\u91cd\u65b0\u8bbf\u95ee\u7f51\u7ad9\uff0c\u679c\u7136\u5feb\u4e86\u5f88\u591a\uff01<\/section>\n<\/div>\n<div class=\"dpu8C _2kCxD \">\n<p>F12\u770b\u4e00\u4e0b\uff0c\u54cd\u5e94\u5934Content-Encoding\u503c\u4e3a\uff1agzip\uff0c\u8bf4\u660egzip\u538b\u7f29\u5df2\u7ecf\u751f\u6548\u4e86\u3002<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u6211\u4eec\u6700\u8fd1\u505a\u7684\u4e00\u4e2a\u9879\u76ee\uff0c\u51fa\u73b0\u4e86\u7f51\u7ad9\u7b2c\u4e00\u6b21\u6253\u5f00\u975e\u5e38\u6162\u7684\u60c5\u51b5\u3002\u7a0d\u5fae\u5206\u6790\u4e00\u4e0b\uff0c\u5c31\u80fd\u770b\u51fa\u95ee\u9898\u3002\u539f\u6765\u662f\u7b2c\u4e00\u6b21\u6253\u5f00\u8981\u90a3\u4e9bjs [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":403,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[26,25],"tags":[71],"_links":{"self":[{"href":"http:\/\/www.esufy.cn\/index.php?rest_route=\/wp\/v2\/posts\/401"}],"collection":[{"href":"http:\/\/www.esufy.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.esufy.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.esufy.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.esufy.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=401"}],"version-history":[{"count":1,"href":"http:\/\/www.esufy.cn\/index.php?rest_route=\/wp\/v2\/posts\/401\/revisions"}],"predecessor-version":[{"id":402,"href":"http:\/\/www.esufy.cn\/index.php?rest_route=\/wp\/v2\/posts\/401\/revisions\/402"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/www.esufy.cn\/index.php?rest_route=\/wp\/v2\/media\/403"}],"wp:attachment":[{"href":"http:\/\/www.esufy.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=401"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.esufy.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=401"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.esufy.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=401"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}