{"id":670,"date":"2018-09-27T12:07:18","date_gmt":"2018-09-27T04:07:18","guid":{"rendered":"http:\/\/cmesoft.com\/?p=670"},"modified":"2018-09-27T12:15:44","modified_gmt":"2018-09-27T04:15:44","slug":"suse-%e4%b8%8aapache-%e5%90%af%e7%94%a8-module_headers-%e5%b9%b6%e9%85%8d%e7%bd%ae-cache-control","status":"publish","type":"post","link":"http:\/\/cmesoft.com\/?p=670","title":{"rendered":"suse \u4e0aapache \u542f\u7528 module_headers \u5e76\u914d\u7f6e cache-control"},"content":{"rendered":"<h2>\u542f\u7528 headers_moule<\/h2>\n<p>\u5728 centos \u914d\u7f6e\u6bd4\u8f83\u7b80\u5355\uff0c\u53ea\u9700\u8981 loadmodules \u5373\u53ef\uff1a<br \/>\n <code lang=\"bash\"><br \/>\n cat \/etc\/httpd\/conf.modules.d\/00-base.conf  | grep headers<br \/>\n LoadModule headers_module modules\/mod_headers.so<br \/>\n<\/code><\/p>\n<p>\u4f46\u5728 suse \u4e0a\uff0c\u5374\u662f\u901a\u8fc7 sysconfig \u6765\u914d\u7f6e\u7684\uff1a<\/p>\n<p><code><br \/>\n cat  \/etc\/sysconfig\/apache2 | grep MODULES | grep -v \"^#\"<br \/>\nAPACHE_MODULES=\"actions alias auth_basic authn_core authn_file authz_core authz_groupfile authz_host authz_user autoindex cgi dir env expires include log_config mime negotiation perl reqtimeout setenvif socache_shmcb ssl userdir headers\"<br \/>\n<\/code><br \/>\n\u9700\u8981\u7f16\u8f91\u8fd9\u884c\u5185\u5bb9\uff0c\u5e76\u4e14\u5982\u679c \/usr\/lib64\/apache2 \u4e0b\u6709 so \u6587\u4ef6\u5373\u53ef\u3002\u67e5\u770b\u6a21\u5757\u65b9\u5f0f\u5982\u4e0b\uff1a<br \/>\n<code><br \/>\n\/usr\/sbin\/apache2ctl -t -D DUMP_MODULES   | grep shared<br \/>\nAH00557: httpd-prefork: apr_sockaddr_info_get() failed for mirrors<br \/>\nAH00558: httpd-prefork: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message<br \/>\n actions_module (shared)<br \/>\n alias_module (shared)<br \/>\n auth_basic_module (shared)<br \/>\n authn_core_module (shared)<br \/>\n authn_file_module (shared)<br \/>\n authz_core_module (shared)<br \/>\n authz_groupfile_module (shared)<br \/>\n authz_host_module (shared)<br \/>\n authz_user_module (shared)<br \/>\n autoindex_module (shared)<br \/>\n cgi_module (shared)<br \/>\n dir_module (shared)<br \/>\n env_module (shared)<br \/>\n expires_module (shared)<br \/>\n include_module (shared)<br \/>\n log_config_module (shared)<br \/>\n mime_module (shared)<br \/>\n negotiation_module (shared)<br \/>\n perl_module (shared)<br \/>\n reqtimeout_module (shared)<br \/>\n setenvif_module (shared)<br \/>\n socache_shmcb_module (shared)<br \/>\n ssl_module (shared)<br \/>\n userdir_module (shared)<br \/>\n headers_module (shared)<br \/>\n <\/code><br \/>\n \u5176\u4e2d\u9759\u6001\u548c\u52a8\u6001\u52a0\u8f7d\u7684\u90fd\u663e\u793a\u51fa\u6765\u4e86\u3002<\/p>\n<p>## \u914d\u7f6eheader\u4e2d\u7684cache-control<\/p>\n<p>\u6bd4\u5982\u5176\u4e2d\u7684\u4e00\u4e2a\u914d\u7f6e\u4e3a\uff1a<br \/>\n <code><br \/>\n <IfModule mod_perl.c><br \/>\n    PerlRequire \"\/etc\/apache2\/smt-mod_perl-startup.pl\"<\/p>\n<pre><code>Alias \"\/SUSE\" \"\/srv\/www\/htdocs\/repo\/SUSE\"\nAlias repo \"\/srv\/www\/htdocs\/repo\"\n\n&lt;Directory \"\/srv\/www\/htdocs\/repo\"&gt;\n    Options +Indexes +FollowSymLinks\n    IndexOptions +NameWidth=*\n    PerlAuthenHandler NU::SMTAuth\n    AuthName SMTAuth\n    AuthType Basic\n    Require valid-user\n\n    &lt;IfModule mod_headers.c&gt;\n            Header set Via \"host-name\"\n            Header set Cache-Control \"max-age=43200\"\n            &lt;FilesMatch \"\\.(xml|xm_|gz|sh|conf|tar|repo|bz2)$\"&gt;\n                    Header set Cache-Control \"max-age=300\"\n            &lt;\/FilesMatch&gt;\n    &lt;\/IfModule&gt;\n\n    # Allow unauthenticated access to \/repo\/tools\/ directory\n    Require expr %{REQUEST_URI} =~ m#^\/repo\/tools\/.*#\n&lt;\/Directory&gt;\n<\/code><\/pre>\n<p><\/IfModule><br \/>\n<\/code><br \/>\n\u8bbe\u7f6e\u4e86\u4e24\u4e2a header, \u5e76\u4e14\u6839\u636e\u6587\u4ef6\u540e\u7f00\u6765\u8bbe\u7f6e\u4e0d\u540c\u7684\u503c\u3002<\/p>\n<h2>\u9a8c\u8bc1\u6548\u679c<\/h2>\n<h3>xml \u6587\u4ef6<\/h3>\n<p><code><br \/>\ncurl -I  http:\/\/localhost\/repo\/SUSE\/Updates\/SLE-SAP\/12-SP2\/x86_64\/update\/repodata\/repomd.xml<br \/>\nHTTP\/1.1 200 OK<br \/>\nDate: Thu, 27 Sep 2018 03:41:23 GMT<br \/>\nServer: Apache<br \/>\nLast-Modified: Tue, 25 Sep 2018 16:06:01 GMT<br \/>\nETag: \"c22-576b448324c40\"<br \/>\nAccept-Ranges: bytes<br \/>\nContent-Length: 3106<br \/>\nVia: smt-root-b<br \/>\nCache-Control: max-age=300<br \/>\nContent-Type: text\/xml<br \/>\n<\/code><\/p>\n<h3>\u5176\u4ed6\u6587\u4ef6<\/h3>\n<p><code><br \/>\ncurl -I  http:\/\/localhost\/repo\/SUSE\/Updates\/SLE-SAP\/12-SP2\/x86_64\/update\/x86_64\/MozillaFirefox-52.8.0esr-109.31.2.x86_64.rpm<br \/>\nHTTP\/1.1 200 OK<br \/>\nDate: Thu, 27 Sep 2018 03:41:01 GMT<br \/>\nServer: Apache<br \/>\nLast-Modified: Fri, 18 May 2018 06:05:07 GMT<br \/>\nETag: \"2bfe4cd-56c74bbd72ac0\"<br \/>\nAccept-Ranges: bytes<br \/>\nContent-Length: 46130381<br \/>\nVia: smt-root-b<br \/>\nCache-Control: max-age=43200<br \/>\nContent-Type: application\/x-rpm<br \/>\n<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u542f\u7528 headers_moule \u5728 centos \u914d\u7f6e\u6bd4\u8f83\u7b80\u5355\uff0c\u53ea\u9700\u8981 loadmodules \u5373\u53ef\uff1a ca&hellip;&nbsp;<a href=\"http:\/\/cmesoft.com\/?p=670\" rel=\"bookmark\">Read More &raquo;<span class=\"screen-reader-text\">suse \u4e0aapache \u542f\u7528 module_headers \u5e76\u914d\u7f6e cache-control<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"neve_meta_sidebar":"","neve_meta_container":"","neve_meta_enable_content_width":"","neve_meta_content_width":0,"neve_meta_title_alignment":"","neve_meta_author_avatar":"","neve_post_elements_order":"","neve_meta_disable_header":"","neve_meta_disable_footer":"","neve_meta_disable_title":"","footnotes":""},"categories":[41],"tags":[],"class_list":["post-670","post","type-post","status-publish","format-standard","hentry","category-web"],"_links":{"self":[{"href":"http:\/\/cmesoft.com\/index.php?rest_route=\/wp\/v2\/posts\/670","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/cmesoft.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/cmesoft.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/cmesoft.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/cmesoft.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=670"}],"version-history":[{"count":8,"href":"http:\/\/cmesoft.com\/index.php?rest_route=\/wp\/v2\/posts\/670\/revisions"}],"predecessor-version":[{"id":678,"href":"http:\/\/cmesoft.com\/index.php?rest_route=\/wp\/v2\/posts\/670\/revisions\/678"}],"wp:attachment":[{"href":"http:\/\/cmesoft.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=670"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/cmesoft.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=670"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/cmesoft.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=670"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}