{"id":5592,"date":"2024-01-07T14:10:15","date_gmt":"2024-01-07T06:10:15","guid":{"rendered":"https:\/\/ixyzero.com\/blog\/?p=5592"},"modified":"2024-01-07T14:10:15","modified_gmt":"2024-01-07T06:10:15","slug":"nginx%e6%97%a5%e5%bf%97%e5%88%86%e6%9e%90-mime-types","status":"publish","type":"post","link":"https:\/\/ixyzero.com\/blog\/archives\/5592.html","title":{"rendered":"Nginx\u65e5\u5fd7\u5206\u6790-MIME types"},"content":{"rendered":"\n<p>=Start=<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u7f18\u7531\uff1a<\/h4>\n\n\n\n<p>Nginx\u65e5\u5fd7\u7684\u5206\u6790\uff0c\u5c24\u5176\u662f\u52a0\u767d\uff0c\u5728\u4e0d\u662f\u7279\u522b\u6e05\u695a\u529f\u80fd\u548c\u4f5c\u7528\u7684\u60c5\u51b5\u4e0b\uff0c\u8fd8\u662f\u5e94\u8be5\u7ec6\u7c92\u5ea6\u7684\u64cd\u4f5c\uff0c\u6bd4\u5982\u5148\u6309\u7167Content-Type\u52a0\u767d\uff0c\u5c31\u6bd4\u6309\u7167domain\u7ef4\u5ea6\u7684\u52a0\u767d\u7c92\u5ea6\u4f1a\u66f4\u7ec6\u4e00\u70b9\uff0c\u6bd4\u6309\u7167uri\u6765\u52a0\u767d\u8981\u66f4\u65b9\u4fbf\u548c\u51c6\u786e\u4e00\u70b9\u3002\u7b80\u5355\u8bb0\u5f55\u4e00\u4e0b\uff0c\u65b9\u4fbf\u540e\u9762\u6709\u9700\u8981\u7684\u65f6\u5019\u53c2\u8003\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u6b63\u6587\uff1a<\/h4>\n\n\n\n<h5 class=\"wp-block-heading\">\u53c2\u8003\u89e3\u7b54\uff1a<\/h5>\n\n\n\n<p>\u547d\u540d\u683c\u5f0f\u4ee5\u53ca\u7c7b\u578b<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>A media type consists of a type and a subtype, which is further structured into a tree. A media type can optionally define a suffix and parameters:\n\nmime-type = type \"\/\" &#91;tree \".\"] subtype &#91;\"+\" suffix]* &#91;\";\" parameter];\n\n\u7c7b\u578b-type\nThe \"type\" part defines the broad use of the media type. As of November 1996, the registered types were: application, audio, image, message, multipart, text and video. By December 2020, the registered types included the foregoing, plus font, example, and model.\nAn unofficial top-level type in common use is chemical.\n\n* application\n* audio\n* image\n* message\n* multipart\n* text\n* video\n* font\n* example\n* model<\/code><\/pre>\n\n\n\n<p>\u65e5\u5e38\u5206\u6790\u4e2d\u9700\u8981\u5173\u6ce8\u548c\u6392\u9664\u7684\u5e38\u89c1Content-Type<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\u751f\u4ea7\u73af\u5883\u4e2d\u5728\u7528\u7684\u79cd\u7c7b\u592a\u591a\uff0c\u524d\u671f\u5148\u7528\u767d\u540d\u5355\u673a\u5236\uff08\u53ea\u5173\u6ce8\u7279\u5b9a\u7684Content-Type\uff09\uff0c\u540e\u9762\u53ef\u4ee5\u91c7\u7528\u9ed1\u660e\u5355\u673a\u5236\uff08\u53ea\u5173\u6ce8\u65b0\u7684Content-Type\uff09\u3002\n\n\u53e6\u5916\u5c31\u662f\uff0c\u7528nginx\u65e5\u5fd7\u4e2d\u7684Content-Type\u5b57\u6bb5\u6765\u5224\u65ad\uff0c\u4e00\u822c\u4f1a\u6bd4\u7528URI\u4e2d\u7684\u540e\u7f00\u6765\u5224\u65ad\u66f4\u5177\u901a\u7528\u6027\u548c\u66f4\u51c6\u3002\n\n,lower(substring_index(http_content_type,';',1)) as http_content_type\n\nand lower(http_content_type) not rlike 'image|video|audio|font|css|javascript'\n\n\n# json\u5b57\u7b26\u4e32\napplication\/json;charset=utf-8\napplication\/json\n\n# \u4efb\u610f\u4e8c\u8fdb\u5236\u6570\u636e\napplication\/octet-stream\n\n# \u7531\u5236\u8868\u7b26\u5206\u9694\u7684 TSV \u6587\u4ef6\u683c\u5f0f\u4e0e CSV \u6587\u4ef6\u683c\u5f0f\u975e\u5e38\u76f8\u4f3c\uff0c\u4f46 CSV \u6587\u4ef6\u4e2d\u5b58\u50a8\u7684\u6570\u636e\u5b57\u6bb5\u662f\u7528\u9017\u53f7\u800c\u4e0d\u662f\u5236\u8868\u7b26\u7a7a\u683c\u5206\u9694\u7684\u3002\u4e24\u8005\u90fd\u662f\u4e00\u79cd\u5206\u9694\u7b26\u5206\u9694\u503c\u683c\u5f0f\u3002\ntext\/tab-separated-values;charset=utf-8\n\n# \u6587\u672c\ntext\/plain\ntext\/json #\u975eIANA\u5b98\u65b9\u63a8\u8350\u7684json\u5b57\u7b26\u4e32\u7c7b\u578b\uff0c\u4f46\u6d4f\u89c8\u5668\u4e5f\u80fd\u8bc6\u522b\u548c\u652f\u6301\ntext\/html\ntext\/xml\n\u2026\u2026\n\n# \u9700\u8981\u6392\u9664\u7684\u4e00\u4e9bMIME\u7c7b\u578b\n\n# js\/css\ntext\/javascript;charset=utf-8\ntext\/css;charset=utf-8\n\n# \u56fe\u7247\nimage\/gif\nimage\/jpeg\nimage\/png\nimage\/webp\n\n# \u89c6\u9891\nvideo\/mp4\nvideo\/mp2t\n\n# \u97f3\u9891\naudio\/m4a\n\n# \u5b57\u4f53\nfont\/woff2\nfont\/woff\nfont\/ttf\napplication\/font-woff\napplication\/font-woff2<\/code><\/pre>\n\n\n\n<p>vnd\u662f\u4ec0\u4e48\u542b\u4e49<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>vnd indicates vendor-specific MIME types, which means they are MIME types that were introduced by corporate bodies rather than e.g. an Internet consortium.\nvnd\u8868\u793a\u7279\u5b9a\u4f9b\u5e94\u5546\u7684MIME\u7c7b\u578b\uff0c\u8fd9\u610f\u5473\u7740\u5b83\u4eec\u662f\u7531\u6cd5\u4eba\u56e2\u4f53\u5f15\u5165\u7684MIME\u7c7b\u578b\uff0c\u800c\u4e0d\u662f\u4f8b\u5982Internet\u8054\u76df\u3002\n\n.docx    application\/vnd.openxmlformats-officedocument.wordprocessingml.document\n.ico     image\/vnd.microsoft.icon\n.mpkg    application\/vnd.apple.installer+xml #Apple Installer Package<\/code><\/pre>\n\n\n\n<p>\u4e8c\u8fdb\u5236\u6570\u636e<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\u5728 RFC 2046 \u4e2d\uff0capplication\/octet-stream \u88ab\u5b9a\u4e49\u4e3a \"\u4efb\u610f\u4e8c\u8fdb\u5236\u6570\u636e\"\uff0c\u5b83\u4e0e\u90a3\u4e9b\u552f\u4e00\u76ee\u7684\u662f\u4fdd\u5b58\u5230\u78c1\u76d8\u4e0a\u7684\u5b9e\u4f53\u6709\u4e00\u5b9a\u7684\u91cd\u53e0\uff0c\u56e0\u6b64\u4e0d\u5c5e\u4e8e\u4efb\u4f55 \"\u7f51\u7edc\"\u5185\u5bb9\u3002\u6216\u8005\u4ece\u53e6\u4e00\u4e2a\u89d2\u5ea6\u770b\uff0c\u5e94\u7528\/\u516b\u8fdb\u5236\u6d41\u7684\u552f\u4e00\u5b89\u5168\u505a\u6cd5\u5c31\u662f\u5c06\u5176\u4fdd\u5b58\u5230\u6587\u4ef6\u4e2d\uff0c\u5e76\u5e0c\u671b\u522b\u4eba\u77e5\u9053\u5b83\u7684\u7528\u9014\u3002<\/code><\/pre>\n\n\n\n<p>json\u548cjsonscript\u7684MIME\u7c7b\u578b<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>For JSON text:\napplication\/json\n\nFor JSONP (runnable JavaScript) with callback:\napplication\/javascript\n==\nIANA has registered the official MIME Type for JSON as application\/json.\n\nWhen asked about why not text\/json, Crockford seems to have said JSON is not really JavaScript nor text and also IANA was more likely to hand out application\/* than text\/*.\n\nA lot of stuff got put into the text\/* section in the early days that would probably be put into the application\/* section these days.\n\nThe most widely supported non-standard media types are text\/json or text\/javascript. But some big names even use text\/plain.\n==\n\nIANA \u5df2\u5c06 JSON \u7684\u5b98\u65b9 MIME \u7c7b\u578b\u6ce8\u518c\u4e3a application\/json\u3002\n\n\u5f53\u88ab\u95ee\u53ca\u4e3a\u4f55\u4e0d\u6ce8\u518c text\/json \u65f6\uff0cCrockford \u4f3c\u4e4e\u8bf4 JSON \u5e76\u975e\u771f\u6b63\u7684 JavaScript\uff0c\u4e5f\u4e0d\u662f\u6587\u672c\uff0c\u800c\u4e14 IANA \u66f4\u503e\u5411\u4e8e\u6ce8\u518c application\/* \u800c\u975e text\/*\u3002\n\n\u65e9\u671f\u6709\u5f88\u591a\u4e1c\u897f\u88ab\u653e\u5230 text\/* \u90e8\u5206\uff0c\u800c\u73b0\u5728\u8fd9\u4e9b\u4e1c\u897f\u53ef\u80fd\u4f1a\u88ab\u653e\u5230 application\/* \u90e8\u5206\u3002\n\n\u6700\u5e7f\u6cdb\u652f\u6301\u7684\u975e\u6807\u51c6\u5a92\u4f53\u7c7b\u578b\u662f text\/json \u6216 text\/javascript\u3002\u4f46\u6709\u4e9b\u5927\u516c\u53f8\u751a\u81f3\u4f7f\u7528 text\/plain\u3002<\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">\u53c2\u8003\u94fe\u63a5\uff1a<\/h5>\n\n\n\n<p>Common MIME types<br><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/HTTP\/Basics_of_HTTP\/MIME_types\/Common_types\">https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/HTTP\/Basics_of_HTTP\/MIME_types\/Common_types<\/a><\/p>\n\n\n\n<p>MIME types (IANA media types)<br><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/HTTP\/Basics_of_HTTP\/MIME_types\">https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/HTTP\/Basics_of_HTTP\/MIME_types<\/a><\/p>\n\n\n\n<p>Media Types<br><a href=\"https:\/\/www.iana.org\/assignments\/media-types\/media-types.xhtml\">https:\/\/www.iana.org\/assignments\/media-types\/media-types.xhtml<\/a><\/p>\n\n\n\n<p>What is the meaning of &#8220;vnd&#8221; in MIME types?<br><a href=\"https:\/\/stackoverflow.com\/questions\/5351093\/what-is-the-meaning-of-vnd-in-mime-types\">https:\/\/stackoverflow.com\/questions\/5351093\/what-is-the-meaning-of-vnd-in-mime-types<\/a><\/p>\n\n\n\n<p>Do I need Content-Type: application\/octet-stream for file download?<br><a href=\"https:\/\/stackoverflow.com\/questions\/20508788\/do-i-need-content-type-application-octet-stream-for-file-download\">https:\/\/stackoverflow.com\/questions\/20508788\/do-i-need-content-type-application-octet-stream-for-file-download<\/a><\/p>\n\n\n\n<p>Which JSON content type do I use?<br><a href=\"https:\/\/stackoverflow.com\/questions\/477816\/which-json-content-type-do-i-use\">https:\/\/stackoverflow.com\/questions\/477816\/which-json-content-type-do-i-use<\/a><\/p>\n\n\n\n<p>Media type<br><a href=\"https:\/\/en.wikipedia.org\/wiki\/Media_type\">https:\/\/en.wikipedia.org\/wiki\/Media_type<\/a><\/p>\n\n\n\n<p>=END=<\/p>\n","protected":false},"excerpt":{"rendered":"<p>=Start= \u7f18\u7531\uff1a Nginx\u65e5\u5fd7\u7684\u5206\u6790\uff0c\u5c24\u5176\u662f\u52a0\u767d\uff0c\u5728\u4e0d\u662f\u7279\u522b\u6e05\u695a\u529f\u80fd\u548c\u4f5c\u7528\u7684\u60c5\u51b5\u4e0b\uff0c\u8fd8\u662f\u5e94\u8be5\u7ec6\u7c92\u5ea6\u7684\u64cd [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23,7],"tags":[2030,181,2114,75,1262],"class_list":["post-5592","post","type-post","status-publish","format-standard","hentry","category-knowledgebase-2","category-programing","tag-content-type","tag-json","tag-mime-types","tag-nginx","tag-sql"],"views":1849,"_links":{"self":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/5592","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/comments?post=5592"}],"version-history":[{"count":1,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/5592\/revisions"}],"predecessor-version":[{"id":5593,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/5592\/revisions\/5593"}],"wp:attachment":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/media?parent=5592"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/categories?post=5592"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/tags?post=5592"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}