{"id":1281,"date":"2012-01-10T16:07:25","date_gmt":"2012-01-10T08:07:25","guid":{"rendered":"http:\/\/doophp.sinaapp.com\/?p=1281"},"modified":"2012-01-10T16:07:25","modified_gmt":"2012-01-10T08:07:25","slug":"post-redirect-get-prg-pattern","status":"publish","type":"post","link":"https:\/\/blog.vimge.com\/archives\/other\/post-redirect-get-prg-pattern.html","title":{"rendered":"Web\u5f00\u53d1\u8bbe\u8ba1\u6a21\u5f0fPRG\uff1aPost\/Redirect\/Get\uff0c\u9632\u6b62\u91cd\u590d\u63d0\u4ea4\u8868\u5355"},"content":{"rendered":"

Post\/Redirect\/Get \u7b80\u79f0PRG\uff0c\u662f\u4e00\u79cd\u7528\u6765\u9632\u6b62\u8868\u5355\u91cd\u590d\u63d0\u4ea4\u6570\u636e\u7684\u4e00\u79cdWeb\u8bbe\u8ba1\u6a21\u5f0f\uff0c\u5178\u578b\u7684\u91cd\u590d\u63d0\u4ea4form\u5185\u5bb9\u7684\u60c5\u51b5\u50cf\u7528\u6237\u5237\u65b0\u63d0\u4ea4\u54cd\u5e94\u9875\u9762\u7b49\u53ef\u901a\u8fc7PRG\u6a21\u5f0f\u6765\u5f97\u5230\u907f\u514d\u3002<\/p>\n

\u5f53\u4e00\u4e2a\u8868\u5355\u901a\u8fc7HTTP POST\u88ab\u8bf7\u6c42\u63d0\u4ea4\u7684\u65f6\u5019\uff0c\u7528\u6237\u5728\u670d\u52a1\u5668\u7aef\u8fd4\u56de\u54cd\u5e94\u671f\u95f4\u5982\u679c\u5237\u65b0\u4e86\u54cd\u5e94\u9875\u9762\uff0c\u5c06\u4f1a\u5bfc\u81f4\u539f\u59cbHTTP POST\u8fc7\u6765\u7684\u5185\u5bb9\u91cd\u590d\u63d0\u4ea4\uff0c\u53ef\u80fd\u4f1a\u5bfc\u81f4\u4e00\u4e9b\u4e0d\u53ef\u9884\u671f\u7684\u7ed3\u679c\uff0c\u6bd4\u5982\u91cd\u590d\u63d0\u4ea4\u6570\u636e\u3002<\/p>\n

\"\"<\/a>
\n
\n\u901a\u5e38\u6211\u4eec\u53ef\u4ee5\u91c7\u7528PRG\u6a21\u5f0f\u6765\u56de\u907f\u91cd\u590d\u63d0\u4ea4\u6570\u636e\u95ee\u9898\u3002PRG\u6a21\u5f0f\u901a\u8fc7\u54cd\u5e94\u9875\u9762Header\u8fd4\u56deHTTP\u72b6\u6001\u7801\u8fdb\u884c\u9875\u9762\u8df3\u8f6c\u66ff\u4ee3\u54cd\u5e94\u9875\u9762\u8df3\u8f6c\u8fc7\u7a0b\u3002PRG\u6a21\u5f0f\u6d41\u7a0b\u5982\u4e0b\u56fe\u793a\uff1a<\/p>\n

\"\"<\/a><\/p>\n

HTTP 1.1 \u89c4\u8303\u4ecb\u7ecdHTTP 303U\u72b6\u6001\u9875\u8fdb\u884c\u8df3\u8f6c\uff0c303\u72b6\u6001\u80fd\u786e\u4fdd\u4f1a\u5458\u5728\u6d4f\u89c8\u5668\u7aef\u5b89\u5168\u5730\u5237\u65b0\u670d\u52a1\u5668\u7aef\u54cd\u5e94\uff0c\u800c\u4e0d\u4f1a\u5f15\u8d77HTTP POST\u8bf7\u6c42\u91cd\u590d\u63d0\u4ea4\u3002\u53e6\u5916\uff0c\u76ee\u524d\u5f88\u591a\u5546\u4e1a\u7f51\u7ad9\u4f9d\u7136\u7ee7\u7eed\u4f7f\u7528HTTP 302\u6765\u54cd\u5e94\u8df3\u8f6c\uff0c\u4e3b\u8981\u8003\u8651\u5230\u4e00\u4e9b\u7248\u672c\u7684\u6d4f\u89c8\u5668\u4e0d\u80fd\u5f88\u597d\u5730\u517c\u5bb9HTTP1.1\u89c4\u8303\u4e2d\u7684303\u72b6\u6001\u7801\u3002<\/p>\n

HTTP\u89c4\u8303\u6458\u5f55\uff1a<\/strong><\/p>\n

302 Found<\/p>\n

\u8bf7\u6c42\u7684\u8d44\u6e90\u73b0\u5728\u4e34\u65f6\u4ece\u4e0d\u540c\u7684URI\u54cd\u5e94\u8bf7\u6c42\u3002\u7531\u4e8e\u8fd9\u6837\u7684\u91cd\u5b9a\u5411\u662f\u4e34\u65f6\u7684\uff0c\u5ba2\u6237\u7aef\u5e94\u5f53\u7ee7\u7eed\u5411\u539f\u6709\u5730\u5740\u53d1\u9001\u4ee5\u540e\u7684\u8bf7\u6c42\u3002\u53ea\u6709\u5728Cache-Control\u6216Expires\u4e2d\u8fdb\u884c\u4e86\u6307\u5b9a\u7684\u60c5\u51b5\u4e0b\uff0c\u8fd9\u4e2a\u54cd\u5e94\u624d\u662f\u53ef\u7f13\u5b58\u7684\u3002<\/p>\n

\u65b0\u7684\u4e34\u65f6\u6027\u7684URI\u5e94\u5f53\u5728\u54cd\u5e94\u7684Location\u57df\u4e2d\u8fd4\u56de\u3002\u9664\u975e\u8fd9\u662f\u4e00\u4e2aHEAD\u8bf7\u6c42\uff0c\u5426\u5219\u54cd\u5e94\u7684\u5b9e\u4f53\u4e2d\u5e94\u5f53\u5305\u542b\u6307\u5411\u65b0\u7684URI\u7684\u8d85\u94fe\u63a5\u53ca\u7b80\u77ed\u8bf4\u660e\u3002<\/p>\n

\u5982\u679c\u8fd9\u4e0d\u662f\u4e00\u4e2aGET\u6216\u8005HEAD\u8bf7\u6c42\uff0c\u90a3\u4e48\u6d4f\u89c8\u5668\u7981\u6b62\u81ea\u52a8\u8fdb\u884c\u91cd\u5b9a\u5411\uff0c\u9664\u975e\u5f97\u5230\u7528\u6237\u7684\u786e\u8ba4\uff0c\u56e0\u4e3a\u8bf7\u6c42\u7684\u6761\u4ef6\u53ef\u80fd\u56e0\u6b64\u53d1\u751f\u53d8\u5316\u3002<\/p>\n

\u6ce8\u610f\uff1a\u867d\u7136RFC 1945\u548cRFC 2068\u89c4\u8303\u4e0d\u5141\u8bb8\u5ba2\u6237\u7aef\u5728\u91cd\u5b9a\u5411\u65f6\u6539\u53d8\u8bf7\u6c42\u7684\u65b9\u6cd5\uff0c\u4f46\u662f\u5f88\u591a\u73b0\u5b58\u7684\u6d4f\u89c8\u5668\u5c06302\u54cd\u5e94\u89c6\u4f5c\u4e3a303\u54cd\u5e94\uff0c\u5e76\u4e14\u4f7f\u7528GET\u65b9\u5f0f\u8bbf\u95ee\u5728Location\u4e2d\u89c4\u5b9a\u7684URI\uff0c\u800c\u65e0\u89c6\u539f\u5148\u8bf7\u6c42\u7684\u65b9\u6cd5\u3002\u72b6\u6001\u7801303\u548c307\u88ab\u6dfb\u52a0\u4e86\u8fdb\u6765\uff0c\u7528\u4ee5\u660e\u786e\u670d\u52a1\u5668\u671f\u5f85\u5ba2\u6237\u7aef\u8fdb\u884c\u4f55\u79cd\u53cd\u5e94\u3002<\/p>\n

303 See Other<\/p>\n

\u5bf9\u5e94\u5f53\u524d\u8bf7\u6c42\u7684\u54cd\u5e94\u53ef\u4ee5\u5728\u53e6\u4e00\u4e2aURI\u4e0a\u88ab\u627e\u5230\uff0c\u800c\u4e14\u5ba2\u6237\u7aef\u5e94\u5f53\u91c7\u7528GET\u7684\u65b9\u5f0f\u8bbf\u95ee\u90a3\u4e2a\u8d44\u6e90\u3002\u8fd9\u4e2a\u65b9\u6cd5\u7684\u5b58\u5728\u4e3b\u8981\u662f\u4e3a\u4e86\u5141\u8bb8\u7531\u811a\u672c\u6fc0\u6d3b\u7684POST\u8bf7\u6c42\u8f93\u51fa\u91cd\u5b9a\u5411\u5230\u4e00\u4e2a\u65b0\u7684\u8d44\u6e90\u3002\u8fd9\u4e2a\u65b0\u7684URI\u4e0d\u662f\u539f\u59cb\u8d44\u6e90\u7684\u66ff\u4ee3\u5f15\u7528\u3002\u540c\u65f6\uff0c303\u54cd\u5e94\u7981\u6b62\u88ab\u7f13\u5b58\u3002\u5f53\u7136\uff0c\u7b2c\u4e8c\u4e2a\u8bf7\u6c42\uff08\u91cd\u5b9a\u5411\uff09\u53ef\u80fd\u88ab\u7f13\u5b58\u3002<\/p>\n

\u65b0\u7684URI\u5e94\u5f53\u5728\u54cd\u5e94\u7684Location\u57df\u4e2d\u8fd4\u56de\u3002\u9664\u975e\u8fd9\u662f\u4e00\u4e2aHEAD\u8bf7\u6c42\uff0c\u5426\u5219\u54cd\u5e94\u7684\u5b9e\u4f53\u4e2d\u5e94\u5f53\u5305\u542b\u6307\u5411\u65b0\u7684URI\u7684\u8d85\u94fe\u63a5\u53ca\u7b80\u77ed\u8bf4\u660e\u3002<\/p>\n

\u6ce8\u610f\uff1a\u8bb8\u591aHTTP\/1.1\u7248\u4ee5\u524d\u7684\u6d4f\u89c8\u5668\u4e0d\u80fd\u6b63\u786e\u7406\u89e3303\u72b6\u6001\u3002\u5982\u679c\u9700\u8981\u8003\u8651\u4e0e\u8fd9\u4e9b\u6d4f\u89c8\u5668\u4e4b\u95f4\u7684\u4e92\u52a8\uff0c302\u72b6\u6001\u7801\u5e94\u8be5\u53ef\u4ee5\u80dc\u4efb\uff0c\u56e0\u4e3a\u5927\u591a\u6570\u7684\u6d4f\u89c8\u5668\u5904\u7406302\u54cd\u5e94\u65f6\u7684\u65b9\u5f0f\u6070\u6070\u5c31\u662f\u4e0a\u8ff0\u89c4\u8303\u8981\u6c42\u5ba2\u6237\u7aef\u5904\u7406303\u54cd\u5e94\u65f6\u5e94\u5f53\u505a\u7684\u3002<\/p><\/blockquote>\n

\u503c\u5f97\u6ce8\u610f\u7684\u662f\uff0cPRG\u8bbe\u8ba1\u6a21\u5f0f\u5e76\u4e0d\u80fd\u9002\u7528\u6240\u6709\u7684\u8868\u5355\u91cd\u590d\u63d0\u4ea4\u60c5\u51b5\uff0c\u5982\u4ee5\u4e0b\u51e0\u79cd\u60c5\u51b5\uff1a<\/p>\n

    \n
  1. \u5982\u679c\u7528\u6237\u8fd4\u56de\u8868\u5355\u9875\u9762\uff0c\u91cd\u65b0\u63d0\u4ea4\u8868\u5355\u7684\u60c5\u51b5<\/li>\n
  2. \u7528\u6237\u5728\u670d\u52a1\u5668\u7aef\u54cd\u5e94\u5230\u8fbe\u4e4b\u524d\uff0c\u591a\u6b21\u70b9\u51fb\u63d0\u4ea4\u6309\u94ae\u7684\u65f6\u5019\u3002(\u53ef\u901a\u8fc7JavaScript\u63a7\u5236\u63d0\u4ea4\u6309\u94ae\u70b9\u51fb\u6b21\u6570)<\/li>\n
  3. \u7531\u4e8e\u670d\u52a1\u5668\u54cd\u5e94\u7f13\u6162\uff0c\u7528\u6237\u5237\u65b0\u63d0\u4ea4POST\u8bf7\u6c42\u9020\u6210\u7684\u591a\u6b21POST\u8bf7\u6c42<\/li>\n
  4. \u6076\u610f\u7528\u6237\u907f\u5f00\u5ba2\u6237\u7aef\u9884\u9632\u591a\u6b21\u63d0\u4ea4\u624b\u6bb5\uff0c\u8fdb\u884c\u91cd\u590d\u63d0\u4ea4\u8bf7\u6c42<\/li>\n<\/ol>\n
    \u9664\u4e86PRG\u8bbe\u8ba1\u6a21\u5f0f\u5916\uff0c\u53e6\u5916\u8fd8\u6709\u4e00\u4e9b\u5176\u4ed6\u6280\u672f\u88ab\u7528\u5728\u9632\u6b62\u8868\u5355\u91cd\u590d\u63d0\u4ea4\u7684\u60c5\u51b5\u4e0b\uff0c\u5982\u5ba2\u6237\u7aef\u6211\u4eec\u53ef\u4ee5\u91c7\u53d6JavaScript\u9632\u6b62\u7528\u6237\u591a\u6b21\u70b9\u51fb\u63d0\u4ea4\u6309\u94ae\uff0c\u8fd8\u53ef\u4ee5\u91c7\u7528Session\u8bb0\u5f55\u7528\u6237\u5f53\u524d\u63d0\u4ea4\u884c\u4e3a\u7b49\u3002<\/div>\n
    \u5f15\u7528\uff1ahttp:\/\/en.wikipedia.org\/wiki\/Post\/Redirect\/Get<\/div>\n","protected":false},"excerpt":{"rendered":"

    Post\/Redirect\/Get \u7b80\u79f0PRG\uff0c\u662f\u4e00\u79cd\u7528\u6765\u9632\u6b62\u8868\u5355\u91cd\u590d\u63d0\u4ea4\u6570\u636e\u7684\u4e00\u79cdWeb\u8bbe\u8ba1\u6a21\u5f0f\uff0c\u5178\u578b\u7684\u91cd\u590d […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1,6],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/posts\/1281"}],"collection":[{"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/comments?post=1281"}],"version-history":[{"count":2,"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/posts\/1281\/revisions"}],"predecessor-version":[{"id":1285,"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/posts\/1281\/revisions\/1285"}],"wp:attachment":[{"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/media?parent=1281"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/categories?post=1281"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/tags?post=1281"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}