{"id":15108,"date":"2024-04-25T00:32:02","date_gmt":"2024-04-24T16:32:02","guid":{"rendered":"https:\/\/blog.iyatt.com\/?p=15108"},"modified":"2024-05-05T12:29:29","modified_gmt":"2024-05-05T04:29:29","slug":"nginx-%e9%80%9a%e8%bf%87%e6%a0%87%e5%a4%b4%e8%ae%a9%e6%b5%8f%e8%a7%88%e5%99%a8%e7%bc%93%e5%ad%98%e9%9d%99%e6%80%81%e6%96%87%e4%bb%b6","status":"publish","type":"post","link":"https:\/\/blog.iyatt.com\/?p=15108","title":{"rendered":"Nginx \u901a\u8fc7\u6807\u5934\u8ba9\u6d4f\u89c8\u5668\u7f13\u5b58\u9759\u6001\u8d44\u6e90\u6587\u4ef6"},"content":{"rendered":"<p>\u57fa\u4e8e Nginx 1.18<br \/>\n\u670d\u52a1\u5668\u9ed8\u8ba4\u914d\u7f6e\u6587\u4ef6\u8def\u5f84\uff1a<strong>\/etc\/nginx\/sites-available\/default<\/strong><\/p>\n<p>\u5b9a\u4e49\u7f13\u5b58\u4e0d\u540c\u6587\u4ef6\u7c7b\u578b\u7684\u65f6\u95f4<\/p>\n<ul>\n<li>off \u6ca1\u6709\u660e\u786e\u7684\u7f13\u5b58\u8981\u6c42<\/li>\n<li>epoch \u8ba9\u6d4f\u89c8\u5668\u59cb\u7ec8\u68c0\u67e5\u662f\u5426\u4e3a\u6700\u65b0<\/li>\n<li>max \u8ba9\u6d4f\u89c8\u5668\u5c3d\u53ef\u80fd\u957f\u65f6\u95f4\u7f13\u5b58\u8fd9\u4e9b\u6587\u4ef6\uff0c\u51cf\u5c0f\u8bf7\u6c42\u6570\u91cf\n<pre><code class=\"language-c\">map $sent_http_content_type $expires {\ndefault                    off;\ntext\/html                  epoch;\ntext\/css                   max;\napplication\/javascript     max;\n~image\/                    max;\n~font\/                     max;\n}<\/code><\/pre>\n<p><img decoding=\"async\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2024\/04\/image-1713975961981.png\" alt=\"file\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 1026px; --smush-placeholder-aspect-ratio: 1026\/388;\" \/><\/p>\n<\/li>\n<\/ul>\n<p>\u7136\u540e\u5728\u76d1\u542c\u7684\u670d\u52a1\u4e2d\u6dfb\u52a0\u7f13\u5b58\u6807\u5934<\/p>\n<pre><code class=\"language-c\">expires $expires;<\/code><\/pre>\n<p><img decoding=\"async\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2024\/04\/image-1713976279335.png\" alt=\"file\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 1093px; --smush-placeholder-aspect-ratio: 1093\/597;\" \/><\/p>\n<p>\u6700\u540e\u91cd\u542f\u670d\u52a1\u5668\u751f\u6548<\/p>\n<pre><code class=\"language-c\">sudo service nginx restart<\/code><\/pre>\n<p>\u7f13\u5b58\u8fc7\u7684\u8d44\u6e90\u6587\u4ef6\u4f1a\u4ece\u672c\u5730\u76f4\u63a5\u52a0\u8f7d\uff0c\u800c\u4e0d\u4f1a\u518d\u6b21\u5411\u670d\u52a1\u5668\u8bf7\u6c42<br \/>\n<img decoding=\"async\" data-src=\"https:\/\/blog.iyatt.com\/wp-content\/uploads\/2024\/04\/image-1713977274884.png\" alt=\"file\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" class=\"lazyload\" style=\"--smush-placeholder-width: 639px; --smush-placeholder-aspect-ratio: 639\/1254;\" \/><\/p>\n<hr \/>\n<p>\u53c2\u8003\uff1a<a href=\"https:\/\/www.digitalocean.com\/community\/tutorials\/how-to-implement-browser-caching-with-nginx-s-header-module-on-ubuntu-20-04\">https:\/\/www.digitalocean.com\/community\/tutorials\/how-to-implement-browser-caching-with-nginx-s-header-module-on-ubuntu-20-04<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u57fa\u4e8e Nginx 1.18 \u670d\u52a1\u5668\u9ed8\u8ba4\u914d\u7f6e\u6587\u4ef6\u8def\u5f84\uff1a\/etc\/nginx\/sites-available\/de [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"zakra_page_container_layout":"customizer","zakra_page_sidebar_layout":"customizer","zakra_remove_content_margin":false,"zakra_sidebar":"customizer","zakra_transparent_header":"customizer","zakra_logo":0,"zakra_main_header_style":"default","zakra_menu_item_color":"","zakra_menu_item_hover_color":"","zakra_menu_item_active_color":"","zakra_menu_active_style":"","zakra_page_header":true,"_lmt_disableupdate":"no","_lmt_disable":"no","footnotes":""},"categories":[1,596],"tags":[],"class_list":["post-15108","post","type-post","status-publish","format-standard","hentry","category-all","category-nginx"],"modified_by":"IYATT-yx","_links":{"self":[{"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=\/wp\/v2\/posts\/15108","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=15108"}],"version-history":[{"count":0,"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=\/wp\/v2\/posts\/15108\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=15108"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=15108"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.iyatt.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=15108"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}