{"id":352,"date":"2013-06-21T15:54:19","date_gmt":"2013-06-21T07:54:19","guid":{"rendered":"http:\/\/www.ln.la\/?p=352"},"modified":"2013-06-21T15:54:19","modified_gmt":"2013-06-21T07:54:19","slug":"wordpress-cdn-and-cookie-free-domains","status":"publish","type":"post","link":"https:\/\/www.lnlog.cn\/index.php\/2013\/06\/21\/wordpress-cdn-and-cookie-free-domains\/","title":{"rendered":"\u7ed9WordPress\u90e8\u7f72CDN\u52a0\u901f\u548cCookie-Free Domains"},"content":{"rendered":"<p>\u7ed9WordPress\u90e8\u7f72CDN\u52a0\u901f\u548cCookie-Free Domains\uff0c\u96c5\u864e\u7684<a title=\"\u5728\u65b0\u7a97\u53e3\u6253\u5f00 - \u7f51\u9875\u524d\u7aef\u4f18\u531623\u6761\u89c4\u5219\" href=\"http:\/\/developer.yahoo.com\/performance\/rules.html\" target=\"_blank\" rel=\"nofollow noopener\">\u7f51\u9875\u524d\u7aef\u4f18\u531623\u6761<\/a>\u91cc\u5176\u4e2d\u4e24\u6761\u662f\uff1a<strong>\u4f7f\u7528\u5185\u5bb9\u5206\u53d1\u7f51\u7edc(Use a Content Delivery Network (CDN))<\/strong>\uff0c<strong>\u4f7f\u7528\u65e0cookie\u7684\u57df(Use Cookie-Free Domains for Components)<\/strong>\u3002<\/p>\n<p><span style=\"color: #ff6600;\">\u7b2c\u4e00\u6b65\uff08\u65b9\u6cd5\u4e00\uff09\uff1a<\/span><\/p>\n<p>\u8fd9\u4e24\u70b9\u5bf9\u4f7f\u7528WordPress\u5f00\u53d1\u7684\u7f51\u7ad9\u6765\u8bf4\u53ef\u80fd\u96be\u4e8e\u5b9e\u73b0\uff0c\u5176\u5b9e\u6211\u4eec\u53ea\u9700\u8981\u5728 wp-congif.php \u91cc\u589e\u52a0\u4e24\u4e2a\u53c2\u6570\u5c31\u53ef\u4ee5\u641e\u5b9a\u3002\u6253\u5f00 wp-config.php ,\u589e\u52a0\u4e0b\u9762\u7684\u5185\u5bb9\uff1a<\/p>\n<div>\n<div id=\"highlighter_191673\">\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td>\n<div>1<\/div>\n<div>2<\/div>\n<\/td>\n<td>\n<div>\n<div><code>define(<\/code><code>\"WP_CONTENT_URL\"<\/code><code>, <\/code><code>\"http:\/\/content.ln.la\/wp-content\"<\/code><code>);<\/code><\/div>\n<div><code>define(<\/code><code>\"COOKIE_DOMAIN\"<\/code><code>, <\/code><code>www.ln.la<\/code><code>);<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u6211\u7684\u76ee\u7684\u662f\u628a wp-content \u76ee\u5f55\u91cc\u7684\u5185\u5bb9\u90fd\u901a\u8fc7 content.ln.la\u8fd9\u4e2a\u57df\u540d\u6765\u52a0\u8f7d\uff0c\u8fd9\u70b9\u5e76\u4e0d\u9700\u8981\u4f7f\u7528\u771f\u6b63\u7684 CDN \u670d\u52a1\u6765\u5b9e\u73b0\uff0c\u53ea\u9700\u8981\u628acontent.ln.la \u4e5f\u6307\u5411\u4e3b\u57df\u540d\u7684\u6839\u76ee\u5f55\u5c31\u53ef\u4ee5\u3002<\/p>\n<p>\u53e6\u5916\u6211\u901a\u8fc7 COOKIE_DOMAIN \u5e38\u91cf\u6765\u9650\u5236 cookie \u7684\u4f5c\u7528\u57df\uff0c\u56e0\u6b64\u5f53\u6d4f\u89c8\u5668\u52a0\u8f7d content.ln.la \u91cc\u7684\u5185\u5bb9\u65f6\uff0crequest header\u91cc\u4e0d\u4f1a\u5e26\u6709\u4e3b\u57df\u7684 cookie\uff0c\u8282\u7ea6\u4e86\u4f20\u8f93\u5e26\u5bbd\uff0c\u8fbe\u5230\u63d0\u9ad8\u52a0\u8f7d\u901f\u5ea6\u7684\u76ee\u7684\u3002<\/p>\n<p><!--more--><\/p>\n<p><span style=\"color: #ff6600;\">\u7b2c\u4e8c\u6b65\uff08\u65b9\u6cd5\u4e8c\uff09\uff1a<\/span><\/p>\n<p>\u8bbe\u7f6eCookie Free\u57df\u540d\u6709\u4e24\u79cd\u65b9\u5f0f\uff0c\u4e00\u662f\u7528\u540c\u57df\u4e0b\u7684\u4e8c\u7ea7\u57df\u540d\uff0c\u4e8c\u662f\u7528\u72ec\u7acb\u57df\u540d\u3002\u5982\u679c\u7f51\u7ad9\u7684\u4e3b\u57df\u662f\u7528\u7684\u8ddf\u57df\u540d\uff0c\u90a3\u4e48\u65b9\u6cd5\u4e00\u65e0\u6548\uff0c\u56e0\u4e3a\u8bbe\u7f6e\u4e86\u8ddf\u57df\u540d\u7684Cookie\u540e\u6240\u6709\u7684\u5b50\u57df\u540d\u90fd\u4f1a\u88ab\u611f\u67d3\u800c\u9644\u5e26Cookie\u3002<\/p>\n<p>\u4e8c\u7ea7\u57df\u540d\u505aCookie Free\u57df\u540d\u7684\u8fd8\u6709\u4e2a\u4e0d\u597d\u662f\u5982\u679c\u4f60\u4f7f\u7528\u4e86\u7f51\u7ad9\u7edf\u8ba1\uff0c\u90a3\u4e48\u53ef\u80fd\u7ad9\u957f\u7edf\u8ba1\u4f1a\u7ed9\u8ddf\u57df\u540d\u52a0\u4e0a\u4e00\u4e9bCookie\uff0c\u4f1a\u5f71\u54cd\u6240\u6709\u5b50\u57df\u540d\uff0c\u6240\u4ee5\u6548\u679c\u4e0d\u662f\u5f88\u597d\uff0c\u6240\u4ee5\u72ec\u7acb\u57df\u540d\u624d\u662f\u738b\u9053\uff01\u65b9\u6cd5\u66f4\u7b80\u5355\uff0c\u53ea\u9700\u8981\u5c06\u4e0a\u9762\u7b2c\u4e8c\u884c\u4e2d\u7684content.ln.la\u6362\u6210\u72ec\u7acbCookie Free\u57df\u540d\u5c31\u53ef\u4ee5\u4e86\uff0c\u7b2c\u4e00\u884c\u53ef\u8981\u53ef\u4e0d\u8981\u4e86\u3002<\/p>\n<p><span style=\"color: #ff6600;\">\u7b2c\u4e09\u6b65(\u6216\u8005\u7b2c\u56db\u6b65)\uff1a<\/span><\/p>\n<p>\u5b89\u88c5wordpress\u63d2\u4ef6Autoptimize\uff0c\u8bbe\u7f6eCDN Options\uff0c\u5f00\u542fRewrite JavaScript URLs\uff0cRewrite CSS URLs\uff0cRewrite Image URLs\uff0c\u540c\u65f6\u8bbe\u7f6e the new base URL\u4e3acontent.ln.la\u6216\u8005\u72ec\u7acbCookie Free\u57df\u540d\u3002<\/p>\n<p><span style=\"color: #ff6600;\">\u7b2c\u56db\u6b65\uff08\u5f3a\u70c8\u63a8\u8350\u7684\u65b9\u6cd5\uff09\u4f46\u662f\u76ee\u524d\u4e0e\u67d0\u4e9b\u63d2\u4ef6\u51b2\u7a81\uff1a<\/span><\/p>\n<p>\u5b89\u88c5wordpress\u63d2\u4ef6WP Super Cache<\/p>\n<p>\u5229\u7528rewrite\u89c4\u5219\uff0c\u5b9e\u73b0\u4ecenginx\u5c42\u9762\u8bbf\u95eewp super cache\u751f\u6210\u7684\u9759\u6001\u7f51\u9875\uff0c\u7ed5\u8fc7PHP\u3002<\/p>\n<p><span style=\"color: #ffcc00;\">location \/ {<\/span><\/p>\n<p><span style=\"color: #ffcc00;\"># \u5982\u679c\u8bf7\u6c42\u7684\u6587\u4ef6\u5df2\u5b58\u5728\uff0c\u76f4\u63a5\u8fd4\u56de<\/span><\/p>\n<p><span style=\"color: #ffcc00;\">if (-f $request_filename) {<\/span><\/p>\n<p><span style=\"color: #ffcc00;\">break;<\/span><\/p>\n<p><span style=\"color: #ffcc00;\">}<\/span><\/p>\n<p><span style=\"color: #ffcc00;\">set $supercache_file &#8221;;<\/span><\/p>\n<p><span style=\"color: #ffcc00;\">set $supercache_uri $request_uri;<\/span><\/p>\n<p><span style=\"color: #ffcc00;\">set $supercache 1;<\/span><\/p>\n<p><span style=\"color: #ffcc00;\">set $ihttp_host &#8221;;<\/span><\/p>\n<p><span style=\"color: #ffcc00;\">\u00a0<\/span><\/p>\n<p><span style=\"color: #ffcc00;\">if ($request_method = POST) {<\/span><\/p>\n<p><span style=\"color: #ffcc00;\">set $supercache 0;<\/span><\/p>\n<p><span style=\"color: #ffcc00;\">}<\/span><\/p>\n<p><span style=\"color: #ffcc00;\">\u00a0<\/span><\/p>\n<p><span style=\"color: #ffcc00;\"># \u4ec5\u5728\u8bbf\u95ee\u6587\u7ae0\u6c38\u4e45\u94fe\u63a5\u65f6\u4f7f\u7528\u9759\u6001\u6587\u4ef6\uff0c\u8bf7\u6c42\u4e2d\u5e26\u53c2\u6570\u5219\u4e0d\u4f7f\u7528\u9759\u6001\u7f13\u5b58<\/span><\/p>\n<p><span style=\"color: #ffcc00;\">set $qs 0;<\/span><\/p>\n<p><span style=\"color: #ffcc00;\">if ($query_string) {<\/span><\/p>\n<p><span style=\"color: #ffcc00;\">set $qs 1;<\/span><\/p>\n<p><span style=\"color: #ffcc00;\">}<\/span><\/p>\n<p><span style=\"color: #ffcc00;\">\u00a0<\/span><\/p>\n<p><span style=\"color: #ffcc00;\"># \u4e0d\u8fc7\u4ece twitter, facebook, feedburner \u94fe\u63a5\u70b9\u8fc7\u6765\u7684\uff0c\u603b\u662f\u5e26\u53c2\u6570\uff0c\u8fd9\u4e9b\u8bbf\u95ee\u4ecd\u7136\u53ef\u4ee5\u4f7f\u7528\u9759\u6001\u6587\u4ef6<\/span><\/p>\n<p><span style=\"color: #ffcc00;\">if ($query_string ~* &#8220;^utm_source=([^&amp;]+)&amp;utm_medium([^&amp;]+)&amp;utm_campaign=([^&amp;]+)(&amp;utm_content=([^&amp;]+))?$&#8221;) {<\/span><\/p>\n<p><span style=\"color: #ffcc00;\">set $qs 0;<\/span><\/p>\n<p><span style=\"color: #ffcc00;\">set $supercache_uri $document_uri;<\/span><\/p>\n<p><span style=\"color: #ffcc00;\">}<\/span><\/p>\n<p><span style=\"color: #ffcc00;\">#deactivate on high load<\/span><\/p>\n<p><span style=\"color: #ffcc00;\">if ($qs = 1) {<\/span><\/p>\n<p><span style=\"color: #ffcc00;\">set $supercache 0;<\/span><\/p>\n<p><span style=\"color: #ffcc00;\">}<\/span><\/p>\n<p><span style=\"color: #ffcc00;\"># \u9488\u5bf9\u5df2\u767b\u5f55\u7528\u6237\uff08\u53d1\u8868\u8fc7\u8bc4\u8bba\uff09\uff0c\u53ef\u4ee5\u4e0d\u9759\u6001\u5316\u3002\u5728\u8bbf\u95ee\u91cf\u9ad8\u5cf0\u65f6\u53ef\u6ce8\u91ca\u6389<\/span><\/p>\n<p><span style=\"color: #ffcc00;\">if ($http_cookie ~* &#8220;comment_author_|wordpress|wp-postpass_&#8221; ) {<\/span><\/p>\n<p><span style=\"color: #ffcc00;\">set $supercache 0;<\/span><\/p>\n<p><span style=\"color: #ffcc00;\">}<\/span><\/p>\n<p><span style=\"color: #ffcc00;\">\u00a0<\/span><\/p>\n<p><span style=\"color: #ffcc00;\"># \u652f\u6301\u79fb\u52a8\u8bbe\u5907\uff0c\u8bbf\u95ee\u79fb\u52a8\u7248\u672c\u7684\u7f51\u9875\u7f13\u5b58<\/span><\/p>\n<p><span style=\"color: #ffcc00;\">if ($http_user_agent ~* &#8216;(iphone|ipod|aspen|incognito|webmate|android|dream|cupcake|froyo|blackberry9500|blackberry9520|blackberry9530|blackberry9550|blackberry 9800|webos|s8000|bada)&#8217;) {<\/span><\/p>\n<p><span style=\"color: #ffcc00;\">set $ihttp_host &#8216;-mobile&#8217;;<\/span><\/p>\n<p><span style=\"color: #ffcc00;\">}<\/span><\/p>\n<p><span style=\"color: #ffcc00;\">\u00a0<\/span><\/p>\n<p><span style=\"color: #ffcc00;\"># \u6307\u5b9a\u9759\u6001\u7f13\u5b58\u6587\u4ef6\u7684\u8def\u5f84<\/span><\/p>\n<p><span style=\"color: #ffcc00;\">if ($supercache = 0) {<\/span><\/p>\n<p><span style=\"color: #ffcc00;\">set $supercache_uri &#8221;;<\/span><\/p>\n<p><span style=\"color: #ffcc00;\">}<\/span><\/p>\n<p><span style=\"color: #ffcc00;\">if ($supercache_uri ~ ^(.+)$) {<\/span><\/p>\n<p><span style=\"color: #ffcc00;\">set $supercache_file \/wp-content\/cache\/supercache\/$http_host$1\/index${ihttp_host}.html;<\/span><\/p>\n<p><span style=\"color: #ffcc00;\">}<\/span><\/p>\n<p><span style=\"color: #ffcc00;\">\u00a0<\/span><\/p>\n<p><span style=\"color: #ffcc00;\"># \u53ea\u6709\u5f53\u7f13\u5b58\u6587\u4ef6\u5b58\u5728\u65f6\uff0c\u624d\u8fdb\u884c rewrite<\/span><\/p>\n<p><span style=\"color: #ffcc00;\">if (-f $document_root$supercache_file) {<\/span><\/p>\n<p><span style=\"color: #ffcc00;\">#rewrite ^(.*)$ $supercache_file break;<\/span><\/p>\n<p><span style=\"color: #ffcc00;\">rewrite ^ $supercache_file last;<\/span><\/p>\n<p><span style=\"color: #ffcc00;\">}<\/span><\/p>\n<p><span style=\"color: #ffcc00;\">\u00a0<\/span><\/p>\n<p><span style=\"color: #ffcc00;\"># \u6240\u6709\u5176\u4ed6\u8bf7\u6c42\uff0c\u8f6c\u7ed9 wordpress \u5904\u7406<\/span><\/p>\n<p><span style=\"color: #ffcc00;\">if (!-e $request_filename) {<\/span><\/p>\n<p><span style=\"color: #ffcc00;\">rewrite . \/index.php last;<\/span><\/p>\n<p><span style=\"color: #ffcc00;\">}<\/span><\/p>\n<p><span style=\"color: #ffcc00;\">}<\/span><\/p>\n<p>\u7528\u4e0a\u9762\u8fd9\u6bb5\u89c4\u5219\u4ee3\u66ffwordpress\u7684\u89c4\u5219\uff0c\u5373wordpress.conf\uff0c\u6216\u8005\u81ea\u5df1\u5efa\u4e00\u4e2aconf\uff0c\u518d\u6dfb\u52a0\u5230vhost\u7684conf\u6587\u4ef6\u4e2d\u3002<\/p>\n<p>\u63a5\u4e0b\u6765\u8bbe\u7f6e\u597d\u540e\uff0c\u63d2\u4ef6\u4f1a\u63d0\u793a\u8bf4\u627e\u4e0d\u5230 mod_rewrite \u6a21\u5757\uff0c\u8fd9\u4e2a\u4e0d\u7528\u7ba1\u5b83\uff0c\u5176\u5b9e\u5df2\u7ecf\u8fbe\u6210\u4f5c\u7528\u4e86\u3002<\/p>\n<p>\u9009\u62e9mod_rewrite \u7f13\u5b58\u6a21\u5f0f\u3002<\/p>\n<p>\u201c\u538b\u7f29\u9875\u9762\u4ee5\u4fbf\u8ba9\u6765\u8bbf\u8005\u66f4\u5feb\u6d4f\u89c8\u3002 (\u63a8\u8350)\u201d\u4e0d\u8981\u9009\u62e9\uff0c\u56e0\u4e3a\u9009\u62e9\u4e86\u4ee5\u540e\uff0c\u670d\u52a1\u5668\u4f1a\u751f\u6210zip\u7684\u6587\u4ef6\uff0c\u6700\u7ec8\u8fd8\u662f\u8981\u901a\u8fc7PHP\u6a21\u5f0f\u6765\u8bbf\u95ee\u3002<\/p>\n<p>\u201c\u7f13\u5b58\u91cd\u5efa\u201d\u548c\u201c\u79fb\u52a8\u8bbe\u5907\u652f\u6301\u201d\u53ef\u4ee5\u9009\u62e9\u3002<\/p>\n<p>\u201c\u5f53\u6709\u65b0\u6587\u7ae0\u6216\u9875\u9762\u7684\u53d1\u5e03\u6216\u66f4\u65b0\u65f6\u6e05\u9664\u4e4b\u524d\u7684\u7f13\u5b58\u6587\u4ef6\u3002\u201d\u8fd9\u4e2a\u9009\u62e9\uff0c\u6bcf\u6b21\u4f60\u53d1\u65b0\u6587\u7ae0\u65f6\u4f1a\u751f\u6210\u65b0\u7684\u7f13\u5b58\u6587\u4ef6\u3002<\/p>\n<p>\u201c\u9996\u9875\u989d\u5916\u68c0\u67e5\u201d\u4e0d\u7528\u9009\u62e9\uff0c\u56e0\u4e3a\u9009\u62e9\u4e86\u540c\u6837\u4f1a\u5360\u7528\u5185\u5b58\u3002<\/p>\n<p>\u201c\u5f53\u67d0\u9875\u9762\u6709\u65b0\u8bc4\u8bba\u65f6\uff0c\u53ea\u5237\u65b0\u8be5\u9875\u9762\u7684\u7f13\u5b58\u3002\u201d\u8fd9\u4e2a\u9009\u62e9\u3002<\/p>\n<p>\u91cd\u8981\uff1a\u7981\u7528\u5783\u573e\u6536\u96c6\u5668\u3002\u5783\u573e\u6536\u96c6\u5668\u4f1a\u6bcf\u9694\u51e0\u5206\u949f\u68c0\u67e5\u7f13\u5b58\uff0c\u8fc7\u671f\u7684\u5c31\u4f1a\u91cd\u5efa\uff0c\u5176\u5b9e\u8fd9\u4e2a\u8fc7\u7a0b\u975e\u5e38\u5730\u5360\u7528\u5185\u5b58\uff0c\u4e00\u5b9a\u8981\u628a\u65f6\u95f4\u8bbe\u4e3a0\uff0c\u9664\u975e\u4f60\u7684\u5185\u5b58\u5f88\u5927\u4e0d\u5728\u4e4e\u3002<\/p>\n<p>\u7136\u540e\u9009\u9879\u5361\u4e0a\u7684\u201c\u9884\u7f13\u5b58\u201d\u4e00\u5b9a\u4e0d\u8981\u8fdb\u884c\u8bbe\u7f6e\u3002<\/p>\n<p>\u8bbe\u7f6e\u597d\u540e\u9000\u51fa\u67e5\u770b\u9875\u9762\u6e90\u6587\u4ef6\u6700\u5e95\u90e8\u5b58\u5728\uff1a<\/p>\n<p>&lt;!&#8211; Dynamic page generated in 0.189 seconds. &#8211;&gt;<\/p>\n<p>&lt;!&#8211; Cached page generated by WP-Super-Cache on 2013-06-21 20:50:49 &#8211;&gt;<\/p>\n<p>&lt;!&#8211; super cache &#8211;&gt;<\/p>\n<p>\u8bf4\u660e\u751f\u6548\u4e86\uff01\u4e00\u5b9a\u8981\u68c0\u67e5\u751f\u6548\u4e0e\u5426\uff0c\u4e0d\u751f\u6548\u8bf4\u660e\u4e0e\u67d0\u4e9b\u63d2\u4ef6\u51b2\u7a81\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7ed9WordPress\u90e8\u7f72CDN\u52a0\u901f\u548cCookie-Free Domains\uff0c\u96c5\u864e\u7684\u7f51\u9875\u524d\u7aef\u4f18\u531623\u6761\u91cc\u5176\u4e2d\u4e24\u6761 &hellip; <a href=\"https:\/\/www.lnlog.cn\/index.php\/2013\/06\/21\/wordpress-cdn-and-cookie-free-domains\/\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u7ed9WordPress\u90e8\u7f72CDN\u52a0\u901f\u548cCookie-Free Domains<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[22,25,29,94],"class_list":["post-352","post","type-post","status-publish","format-standard","hentry","category-tech","tag-autoptimize","tag-cdn","tag-cookie-free-domains","tag-wordpress"],"_links":{"self":[{"href":"https:\/\/www.lnlog.cn\/index.php\/wp-json\/wp\/v2\/posts\/352","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.lnlog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.lnlog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.lnlog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.lnlog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=352"}],"version-history":[{"count":0,"href":"https:\/\/www.lnlog.cn\/index.php\/wp-json\/wp\/v2\/posts\/352\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.lnlog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=352"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.lnlog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=352"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.lnlog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=352"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}