{"id":3407,"date":"2018-05-08T08:25:52","date_gmt":"2018-05-08T00:25:52","guid":{"rendered":"http:\/\/cn.hostease.com\/xueyuan\/?p=3407"},"modified":"2018-05-08T08:25:52","modified_gmt":"2018-05-08T00:25:52","slug":"apache%e5%bc%80%e5%90%af-gzip-%e5%8e%8b%e7%bc%a9%e4%b8%8e%e9%85%8d%e7%bd%ae-expirecache-control-%e5%a4%b4","status":"publish","type":"post","link":"https:\/\/cn.hostease.com\/xueyuan\/uncategorized\/apache%e5%bc%80%e5%90%af-gzip-%e5%8e%8b%e7%bc%a9%e4%b8%8e%e9%85%8d%e7%bd%ae-expirecache-control-%e5%a4%b4\/","title":{"rendered":"Apache\u5f00\u542f gzip \u538b\u7f29\u4e0e\u914d\u7f6e Expire\/Cache-Control \u5934"},"content":{"rendered":"<p><strong>Apache\u5f00\u542f gzip \u538b\u7f29\u65b9\u6cd5\uff1a<\/strong><\/p>\n<p>\u8fd9\u91cc\u6211\u4f7f\u7528\u7684\u662fApache2.4.17<\/p>\n<p>\u6253\u5f00apache\u5b89\u88c5\u76ee\u5f55\uff0c\u627e\u5230conf\u76ee\u5f55\uff0c\u7528\u8bb0\u4e8b\u672c\u6253\u5f00httpd.conf \u6587\u4ef6\u3002<\/p>\n<p>ctrl+f \u67e5\u627e<\/p>\n<p>\u53bb\u6389 #LoadModule headers_module modules\/mod_headers.so \u524d\u9762\u7684\u6ce8\u91ca #<br \/>\n\u53bb\u6389 #LoadModule deflate_module modules\/mod_deflate.so \u524d\u9762\u7684\u6ce8\u91ca #<br \/>\n\u53bb\u6389 #LoadModule filter_module modules\/mod_filter.so \u524d\u9762\u7684\u6ce8\u91ca #<\/p>\n<p><strong>\u6587\u4ef6\u672b\u5c3e\u52a0\u4e0a<\/strong><\/p>\n<p>&lt;IfModule deflate_module&gt;<br \/>\nSetOutputFilter DEFLATE<\/p>\n<p>DeflateCompressionLevel 6<\/p>\n<p>AddOutputFilterByType DEFLATE text\/html text\/plain text\/xml text\/css text\/javascript application\/javascript \u3000\u3000\/\/\u9700\u8981\u538b\u7f29\u7684\u683c\u5f0f<\/p>\n<p>AddOutputFilter DEFLATE css js txt xml rss html htm \u3000\u3000\/\/\u9700\u8981\u538b\u7f29\u7684\u683c\u5f0f<\/p>\n<p>Header append Vary User-Agent env=!dont-vary<\/p>\n<p>SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png|bmp|tif)$ no-gzip dont-vary \u3000\u3000\/\/\u4e0d\u9700\u8981\u538b\u7f29\u7684\u683c\u5f0f<\/p>\n<p>SetEnvIfNoCase Request_URI .(?:exe|t?gz|zip|7z|bz2|sit|rar|bin|iso)$ no-gzip dont-vary \u3000\u3000\/\/\u4e0d\u9700\u8981\u538b\u7f29\u7684\u683c\u5f0f<\/p>\n<p>SetEnvIfNoCase Request_URI .(?:pdf|doc|docx|xls|xlsx|ppt|pptx)$ no-gzip dont-vary \u3000\u3000\/\/\u4e0d\u9700\u8981\u538b\u7f29\u7684\u683c\u5f0f<\/p>\n<p>&lt;\/IfModule&gt;<\/p>\n<p><strong>\u7136\u540e\u770b\u5ba2\u6237\u7aef\u7684\u8bf7\u6c42\u91cc\u662f\u5426\u6709 :<\/strong><\/p>\n<p>Accept-Encoding: gzip, deflate \u3000\u3000\/\/\u4ee3\u8868\u5ba2\u6237\u7aef\u652f\u6301gzip<\/p>\n<p><strong>\u670d\u52a1\u7aef\u7684\u54cd\u5e94\u91cc\u662f\u5426\u6709 :<\/strong><\/p>\n<p>Content-Encoding: gzip\u3000\u3000\u3000\u3000\/\/\u4ee3\u8868\u670d\u52a1\u7aef\u5df2\u5f00\u542fgzip<br \/>\n\u6709\u4e9b\u670d\u52a1\u5668\u5bf9\u5185\u5bb9\u8fdb\u884c gzip \u7f16\u7801\u53ea\u9488\u5bf9\u67d0\u4e9b\u6587\u4ef6,\u6240\u4ee5 \u6709\u6ca1\u6709\u8fd4\u56de \u8fd9\u4e2a,\u5e76\u4e0d\u80fd\u4ee3\u8868,\u662f\u5426\u652f\u6301gzip\u7684\u4f9d\u636e\u3002<\/p>\n<p><strong>Apache\u914d\u7f6e Expire\/Cache-Control \u5934<\/strong><\/p>\n<p>\u6253\u5f00apache\u5b89\u88c5\u76ee\u5f55\uff0c\u627e\u5230conf\u76ee\u5f55\uff0c\u7528\u8bb0\u4e8b\u672c\u6253\u5f00httpd.conf \u6587\u4ef6\u3002<\/p>\n<p>ctrl+f \u67e5\u627e LoadModule expires_module modules\/mod_expires.so<br \/>\n\u53bb\u6389\u524d\u9762 #\u53f7\uff01<\/p>\n<p>\u5728\u6587\u672c\u6700\u540e\u9762\u6dfb\u52a0\uff1a<br \/>\n&lt;IfModule expires_module&gt;<\/p>\n<p>#\u6253\u5f00\u7f13\u5b58<br \/>\nExpiresActive on<br \/>\n#css\u6587\u4ef6\u7f13\u5b587200000\/3600\/24=83\u5929<br \/>\nExpiresByType text\/css A7200000<\/p>\n<p>#js\u6587\u4ef6\u7f13\u5b5883\u5929<br \/>\nExpiresByType application\/x-javascript A7200000<br \/>\nExpiresByType application\/javascript A7200000<\/p>\n<p>#html\u6587\u4ef6\u7f13\u5b5883\u5929<br \/>\nExpiresByType text\/html A7200000<\/p>\n<p>#\u56fe\u7247\u6587\u4ef6\u7f13\u5b5883\u5929<br \/>\nExpiresByType image\/jpeg A7200000<br \/>\nExpiresByType image\/gif A7200000<br \/>\nExpiresByType image\/png A7200000<br \/>\nExpiresByType image\/x-icon A7200000<\/p>\n<p>&lt;\/IfModule&gt;<\/p>\n<p>\u4e0a\u9762\u5f00\u542f\u7684\u662fexpire<\/p>\n<p>\u4e0b\u9762\u662fcache-control<br \/>\n\u5728\u6587\u672c\u540e\u9762\u7ee7\u7eed\u6dfb\u52a0<br \/>\n&lt;FilesMatch &#8220;\\.(flv|gif|jpg|jpeg|png|ico|swf)$&#8221;&gt;<br \/>\nHeader set Cache-Control &#8220;max-age=604800, public&#8221;<br \/>\n&lt;\/FilesMatch&gt;<\/p>\n<p>&lt;FilesMatch &#8220;\\.(css|js)$&#8221;&gt;<br \/>\nHeader set Cache-Control &#8220;max-age=604800, public&#8221;<br \/>\n&lt;\/FilesMatch&gt;<\/p>\n<p>\u8fd9\u91cc\u65f6\u95f4\u8bbe\u7f6e\u4e0d\u4e00\u6837\u662f\u4e3a\u4e86\u68c0\u9a8c\u662f\u5426\u6210\u529f\u914d\u7f6e\u7684\uff0c\u56e0\u4e3a\uff0c\u6ca1\u8bbecache-control\u7684\u65f6\u5019\uff0c\u5b83\u4f1a\u81ea\u52a8\u6839\u636eexpire\u7684\u65f6\u95f4\u8bbe\u7f6e\u81ea\u5df1\u3002<\/p>\n<p>\u6700\u540e\u91cd\u542fapache\u670d\u52a1\u5668\uff0cok\uff01<\/p>\n<p>\u8fd9\u91cc\u8bf4\u4e00\u4e2a\u81ea\u5df1\u722c\u7684\u5751\u5427!\uff08\u90a3\u5c31\u662f\u5982\u679c\u4e0d\u51fa\u73b0 200 form cache\uff0c \u800c\u662f\u51fa\u73b0\u4e86304\uff0c\u90a3\u662f\u56e0\u4e3a\uff0c\u4f60\u5237\u65b0\u4e86\u6d4f\u89c8\u5668\u3002\u3002\u3002\u60f3\u8981\u51fa\u73b0 200 form cache\uff0c\u9700\u8981\u5728\u6d4f\u89c8\u5668\u5730\u5740\u680f\u91cc\u6309\u56de\u8f66\u952e\u3002\uff09<\/p>\n<p>\u4e5f\u5c31\u662f\u8bf4\uff1a\u5237\u65b0\u6d4f\u89c8\u5668 \u89e6\u53d1 304\uff0c \u5730\u5740\u680f\u56de\u8f66\u89e6\u53d1 200 form cache\u3002<\/p>\n<p>\u67e5\u4e86\u597d\u4e45\u624d\u53d1\u73b0\u4e86\uff0c\u4e4b\u524d\u4e00\u76f4\u60f3\u4e0d\u901a\uff0c\u65e2\u7136\u8bbe\u7f6e\u4e86cache-control\u548cexpire\u4e3a\u5565\u8fd8\u662f304\uff0c\u8fd9\u5c31\u662f\u539f\u56e0\uff0c\u5c31\u662f\u8fd9\u4e48\u7b80\u5355\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Apache\u5f00\u542f gzip \u538b\u7f29\u65b9\u6cd5\uff1a \u8fd9\u91cc\u6211\u4f7f\u7528\u7684\u662fApache2.4.17 \u6253\u5f00apache\u5b89\u88c5\u76ee\u5f55\uff0c\u627e\u5230 &#8230; <a title=\"Apache\u5f00\u542f gzip \u538b\u7f29\u4e0e\u914d\u7f6e Expire\/Cache-Control \u5934\" class=\"read-more\" href=\"https:\/\/cn.hostease.com\/xueyuan\/uncategorized\/apache%e5%bc%80%e5%90%af-gzip-%e5%8e%8b%e7%bc%a9%e4%b8%8e%e9%85%8d%e7%bd%ae-expirecache-control-%e5%a4%b4\/\" aria-label=\"\u9605\u8bfb Apache\u5f00\u542f gzip \u538b\u7f29\u4e0e\u914d\u7f6e Expire\/Cache-Control \u5934\">\u9605\u8bfb\u66f4\u591a<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-3407","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/posts\/3407","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/comments?post=3407"}],"version-history":[{"count":1,"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/posts\/3407\/revisions"}],"predecessor-version":[{"id":3408,"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/posts\/3407\/revisions\/3408"}],"wp:attachment":[{"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/media?parent=3407"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/categories?post=3407"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cn.hostease.com\/xueyuan\/wp-json\/wp\/v2\/tags?post=3407"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}