{"id":4646,"date":"2020-04-09T12:48:25","date_gmt":"2020-04-09T05:48:25","guid":{"rendered":"https:\/\/tino.vn\/?post_type=ht_kb&#038;p=4646"},"modified":"2021-06-14T22:57:19","modified_gmt":"2021-06-14T15:57:19","slug":"cach-khac-phuc-canh-bao-serve-static-content-from-a-cookieless-domain","status":"publish","type":"ht_kb","link":"https:\/\/tino.vn\/blog\/docs\/cach-khac-phuc-canh-bao-serve-static-content-from-a-cookieless-domain\/","title":{"rendered":"C\u00e1ch kh\u1eafc ph\u1ee5c c\u1ea3nh b\u00e1o Serve Static Content From a Cookieless Domain"},"content":{"rendered":"<p><span class=\"notranslate\">N\u1ebfu b\u1ea1n nh\u1eadn \u0111\u01b0\u1ee3c m\u1ed9t s\u1ed1 c\u1ea3nh b\u00e1o t\u1eeb c\u00e1c c\u00f4ng c\u1ee5 nh\u01b0\u00a0 Pingdom\u00a0,\u00a0GTmetrix\u00a0ho\u1eb7c\u00a0Google PageSpeed \u200b\u200bInsights v\u1edbi n\u1ed9i dung l\u00e0 &#8220;serve static content from a cookieless domain&#8221; . Th\u1ef1c t\u1ebf l\u00e0<\/span><span class=\"notranslate\"> khi b\u1ea1n \u0111ang cung c\u1ea5p n\u1ed9i dung khi client y\u00eau c\u1ea7u nh\u01b0 h\u00ecnh \u1ea3nh, JavaScript, CSS, th\u00ec kh\u00f4ng c\u00f3 l\u00fd do g\u00ec \u0111\u1ec3 b\u1ea1n ph\u1ea3i g\u1eafn th\u00eam cookie \u0111i k\u00e8m, B\u1edfi v\u00ec n\u00f3 s\u1ebd t\u1ea1o th\u00eam x\u1eed l\u00fd v\u00e0 c\u1ed3ng k\u1ec1nh.<\/span> Nh\u01b0ng m\u00e0, M\u1ed9t khi c\u00e1c webserver thi\u1ebft l\u1eadp m\u1ed9t cookie cho m\u1ed9t t\u00ean mi\u1ec1n c\u1ee5 th\u1ec3, t\u1ea5t c\u1ea3 c\u00e1c y\u00eau c\u1ea7u HTTP ti\u1ebfp theo cho t\u00ean mi\u1ec1n \u0111\u00f3 ph\u1ea3i bao g\u1ed3m c\u00e1c t\u1eadp tin cookie.<\/p>\n<p><span class=\"notranslate\">C\u1ea3nh b\u00e1o n\u00e0y th\u01b0\u1eddng \u0111\u01b0\u1ee3c th\u1ea5y tr\u00ean c\u00e1c trang web c\u00f3 s\u1ed1 l\u01b0\u1ee3ng l\u1edbn request.<\/span>\u00a0<span class=\"notranslate\">M\u1ed9t s\u1ed1 c\u00e1ch \u0111\u1ec3 kh\u1eafc ph\u1ee5c \u0111i\u1ec1u n\u00e0y bao g\u1ed3m s\u1eed d\u1ee5ng CDN lo\u1ea1i b\u1ecf cookie ho\u1eb7c thi\u1ebft l\u1eadp m\u1ed9t t\u00ean mi\u1ec1n ri\u00eang ho\u1eb7c ho\u1eb7c t\u00ean mi\u1ec1n ph\u1ee5 \u0111\u1ec3 ph\u00e2n ph\u00e1t cookie.<\/span><\/p>\n<div class=\"notice notice--info\">\n<pre class=\"notice__content\"><span class=\"notranslate\">Do nh\u1eefng thay \u0111\u1ed5i g\u1ea7n \u0111\u00e2y v\u1edbi web v\u00e0 c\u00e1c giao th\u1ee9c m\u1edbi nh\u01b0 HTTP \/ 2, c\u1ea3nh b\u00e1o n\u00e0y th\u01b0\u1eddng c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c b\u1ecf qua.<\/span>\u00a0\r\nN\u1ebfu s\u1eed d\u1ee5ng hosting\/VPS t\u1ea1i TinoHost, b\u1ea1n kh\u00f4ng c\u1ea7n quan t\u00e2m t\u1edbi l\u1ed7i n\u00e0y.<\/pre>\n<\/div>\n<p>Tu\u1ef3 thu\u1ed9c v\u00e0o c\u00f4ng c\u1ee5 ki\u1ec3m tra , N\u1ed9i dung c\u1ea3nh b\u00e1o c\u00f3 th\u1ec3 \u0111\u01b0\u1ee3c \u0111\u01b0a ra nh\u01b0 sau:<\/p>\n<ul>\n<li>\u201cserve the following static resources from a domain that doesn\u2019t set cookies\u201d<\/li>\n<li>\u201cserve static content from a cookieless domain\u201d<\/li>\n<\/ul>\n<div id=\"attachment_6641\" class=\"wp-caption alignnone\"><img decoding=\"async\" class=\"wp-image-6641 size-full\" src=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/04\/pingdom-serve-static-content-from-a-cookieless-domain-2.png\" alt=\"pingdom ph\u1ee5c v\u1ee5 n\u1ed9i dung t\u0129nh t\u1eeb m\u1ed9t mi\u1ec1n v\u00f4 d\u1ee5ng\" width=\"1700\" height=\"535\" title=\"\"><\/p>\n<p class=\"wp-caption-text\">\n<\/div>\n<h2 id=\"Kh\u1eafc_ph\u1ee5c_ph\u1ee5c_v\u1ee5_n\u1ed9i_dung_t\u0129nh_t\u1eeb_c\u1ea3nh_b\u00e1o_mi\u1ec1n_v\u00f4_d\u1ee5ng\u00a0\"><span class=\"notranslate\">Kh\u1eafc ph\u1ee5c ph\u1ee5c v\u1ee5 n\u1ed9i dung t\u0129nh t\u1eeb c\u1ea3nh b\u00e1o mi\u1ec1n v\u00f4 d\u1ee5ng<\/span>\u00a0<span id=\"khc-phc-phc-v-ni-dung-tnh-t-cnh-bo-min-v-dng\" class=\"anchor-hash\" aria-hidden=\"true\"><\/span><\/h2>\n<p><span class=\"notranslate\">C\u00f3 m\u1ed9t s\u1ed1 c\u00e1ch \u0111\u1ec3 kh\u1eafc ph\u1ee5c:\u00a0 ch\u1eb3ng h\u1ea1n nh\u01b0 s\u1eed d\u1ee5ng CDN v\u00e0 c\u1ea5u h\u00ecnh l\u1ea1i trang web WordPress c\u1ee7a b\u1ea1n.<\/span><\/p>\n<ol>\n<li><span class=\"notranslate\">S\u1eed d\u1ee5ng CDN<\/span><\/li>\n<li><span class=\"notranslate\">C\u1ea5u h\u00ecnh l\u1ea1i trang web WordPress<\/span><\/li>\n<\/ol>\n<h3 id=\"1._S\u1eed_d\u1ee5ng_CDN\u00a0\"><span class=\"notranslate\">1. S\u1eed d\u1ee5ng CDN<\/span>\u00a0<span id=\"cdn\" class=\"anchor-hash\" aria-hidden=\"true\"><\/span><\/h3>\n<p><span class=\"notranslate\">M\u1ed9t c\u00e1ch d\u1ec5 d\u00e0ng \u0111\u1ec3 kh\u1eafc ph\u1ee5c c\u1ea3nh b\u00e1o n\u00e0y l\u00e0 s\u1eed d\u1ee5ng CDN c\u00f3 kh\u1ea3 n\u0103ng b\u1ecf qua cookie c\u0169ng nh\u01b0 lo\u1ea1i b\u1ecf cookie, \u0111i\u1ec1u n\u00e0y s\u1ebd ho\u00e0n to\u00e0n ng\u0103n vi\u1ec7c nh\u1eadn \u0111\u01b0\u1ee3c ph\u1ea3n h\u1ed3i Set-Cookie.<\/span>\u00a0<span class=\"notranslate\">KeyCDN\u00a0l\u00e0 m\u1ed9t nh\u00e0 cung c\u1ea5p CDN cung c\u1ea5p t\u00ednh n\u0103ng n\u00e0y.<\/span>\u00a0<span class=\"notranslate\">Theo m\u1eb7c \u0111\u1ecbnh, b\u1ea1n c\u00f3 th\u1ec3 th\u1ea5y hai t\u00f9y ch\u1ecdn sau \u0111\u01b0\u1ee3c b\u1eadt.<\/span> <img decoding=\"async\" class=\"size-full wp-image-6643 aligncenter\" src=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/04\/cdn-strip-cookies.png\" sizes=\"(max-width: 1386px) 100vw, 1386px\" srcset=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/04\/cdn-strip-cookies.png 1386w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/04\/1_cdn-strip-cookies-300x96.png 300w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/04\/1_cdn-strip-cookies-768x246.png 768w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/04\/1_cdn-strip-cookies-1024x328.png 1024w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/04\/cdn-strip-cookies-460x147.png 460w\" alt=\"cookie d\u1ea3i cdn\" width=\"1386\" height=\"444\" title=\"\"><\/p>\n<p><span class=\"notranslate\">L\u01b0u \u00fd: B\u1ea1n kh\u00f4ng th\u1ec3 t\u1eaft cookie khi s\u1eed d\u1ee5ng CloudFlare.<\/span> M\u00e0 <span class=\"notranslate\">CloudFlare c\u0169ng \u0111\u01b0a ra cookie b\u1ea3o m\u1eadt c\u1ee7a ri\u00eang n\u00f3 t\u1ea1i header.<\/span> V\u1ea3 l\u1ea1i th\u00ec<span class=\"notranslate\"> nh\u1eefng cookie n\u00e0y\u00a0 dung l\u01b0\u1ee3ng r\u1ea5t nh\u1ecf v\u00e0\u00a0 \u0111em l\u1ea1i hi\u1ec7u qu\u1ea3 c\u0169ng c\u1ef1c k\u1ef3 nh\u1ecf.<\/span>\u00a0<span class=\"notranslate\">N\u00ean n\u1ebfu b\u1ea1n s\u1eed d\u1ee5ng CloudFlare, kh\u00f4ng c\u00f3 c\u00e1ch n\u00e0o \u0111\u1ec3 kh\u1eafc ph\u1ee5c c\u1ea3nh b\u00e1o n\u00e0y.<\/span><\/p>\n<h3 id=\"2._C\u1ea5u_h\u00ecnh_l\u1ea1i_trang_web_WordPress\u00a0\"><span class=\"notranslate\">2. C\u1ea5u h\u00ecnh l\u1ea1i trang web WordPress<\/span>\u00a0<span id=\"re-configure-wordpress-site\" class=\"anchor-hash\" aria-hidden=\"true\"><\/span><\/h3>\n<p><span class=\"notranslate\">T\u00f9y ch\u1ecdn th\u1ee9 hai b\u1ea1n l\u00e0 c\u1ea5u h\u00ecnh l\u1ea1i trang web WordPress c\u1ee7a b\u1ea1n \u0111\u1ec3 ph\u00e2n ph\u1ed1i c\u00e1c t\u1ec7p t\u0129nh t\u1eeb m\u1ed9t t\u00ean mi\u1ec1n ho\u1eb7c t\u00ean mi\u1ec1n ph\u1ee5 m\u1edbi.<\/span><\/p>\n<p><span class=\"notranslate\">L\u01b0u \u00fd: N\u1ebfu b\u1ea1n s\u1eed d\u1ee5ng t\u00ean mi\u1ec1n nh\u01b0 domain.com, th\u00ec b\u1ea1n th\u1ef1c s\u1ef1 c\u1ea7n ph\u1ea3i s\u1eed d\u1ee5ng m\u1ed9t t\u00ean mi\u1ec1n kh\u00e1c.<\/span>\u00a0<span class=\"notranslate\">N\u1ebfu b\u1ea1n \u0111ang s\u1eed d\u1ee5ng www.domain.com th\u00ec b\u1ea1n c\u00f3 th\u1ec3 ch\u1ec9 c\u1ea7n thi\u1ebft l\u1eadp m\u1ed9t t\u00ean mi\u1ec1n ph\u1ee5 nh\u01b0 static.domain.com.<\/span>\u00a0<span class=\"notranslate\">Trong v\u00ed d\u1ee5 n\u00e0y, website c\u1ee7a t\u00f4i \u0111ang s\u1eed d\u1ee5ng l\u00e0 www.domain.com.<\/span><\/p>\n<ol>\n<li><span class=\"notranslate\">\u0110\u1ea7u ti\u00ean, t\u1ea1o m\u1ed9t t\u00ean mi\u1ec1n ph\u1ee5 (subdomain) nh\u01b0 static.domain.com.<\/span><\/li>\n<li><span class=\"notranslate\">Thi\u1ebft l\u1eadp b\u1ea3n ghi DNS c\u1ee7a t\u00ean mi\u1ec1n ph\u1ee5 (subdomain) c\u1ee7a b\u1ea1n d\u01b0\u1edbi d\u1ea1ng CNAME tr\u1ecf \u0111\u1ebfn t\u00ean mi\u1ec1n ch\u00ednh c\u1ee7a b\u1ea1n.<\/span><\/li>\n<li><span class=\"notranslate\">Tr\u1ecf t\u00ean mi\u1ec1n ph\u1ee5 c\u1ee7a b\u1ea1n v\u00e0o th\u01b0 m\u1ee5c \/ wp-content b\u1eb1ng c\u00e1ch ch\u1ec9nh s\u1eeda t\u1ec7p wp-config.php c\u1ee7a b\u1ea1n:<\/span><\/li>\n<\/ol>\n<pre>define(\"WP_CONTENT_URL\", \"http:\/\/static.domain.com\"); \r\ndefine(\"<\/pre>\n<p><a href=\"https:\/\/codex.wordpress.org\/Editing_wp-config.php#Set_Cookie_Domain\" target=\"_blank\" rel=\"noopener noreferrer nofollow\">COOKIE_DOMAIN<\/a><\/p>\n<pre>\", \"domain.com\");<\/pre>\n<p>Ch\u00fac c\u00e1c b\u1ea1n th\u00e0nh c\u00f4ng.!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>N\u1ebfu b\u1ea1n nh\u1eadn \u0111\u01b0\u1ee3c m\u1ed9t s\u1ed1 c\u1ea3nh b\u00e1o t\u1eeb c\u00e1c c\u00f4ng c\u1ee5 nh\u01b0\u00a0 Pingdom\u00a0,\u00a0GTmetrix\u00a0ho\u1eb7c\u00a0Google PageSpeed \u200b\u200bInsights v\u1edbi n\u1ed9i dung l\u00e0 &#8220;serve static content from a cookieless domain&#8221; . Th\u1ef1c t\u1ebf l\u00e0 khi b\u1ea1n \u0111ang cung c\u1ea5p n\u1ed9i dung khi client y\u00eau c\u1ea7u nh\u01b0 h\u00ecnh \u1ea3nh, JavaScript, CSS, th\u00ec kh\u00f4ng c\u00f3 l\u00fd do g\u00ec \u0111\u1ec3 b\u1ea1n [&hellip;]<\/p>\n","protected":false},"author":7,"featured_media":16424,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","format":"standard","meta":{"footnotes":""},"tags":[],"ht_kb_category":[5167,5154],"class_list":["post-4646","ht_kb","type-ht_kb","status-publish","format-standard","has-post-thumbnail","hentry","ht_kb_category-cau-hoi-chung-ve-wordpress","ht_kb_category-wordpress"],"_links":{"self":[{"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/ht_kb\/4646","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/ht_kb"}],"about":[{"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/comments?post=4646"}],"version-history":[{"count":0,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/ht_kb\/4646\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/media\/16424"}],"wp:attachment":[{"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/media?parent=4646"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/tags?post=4646"},{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/ht_kb_category?post=4646"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}