{"id":4920,"date":"2020-04-23T15:33:28","date_gmt":"2020-04-23T08:33:28","guid":{"rendered":"https:\/\/tino.vn\/?post_type=ht_kb&#038;p=4920"},"modified":"2021-06-14T22:57:19","modified_gmt":"2021-06-14T15:57:19","slug":"cach-xoa-query-strings-tu-static-resources-trong-wordpress","status":"publish","type":"ht_kb","link":"https:\/\/tino.vn\/blog\/docs\/cach-xoa-query-strings-tu-static-resources-trong-wordpress\/","title":{"rendered":"C\u00e1ch x\u00f3a Query Strings t\u1eeb Static Resources trong WordPress"},"content":{"rendered":"<p><span>Khi n\u00f3i \u0111\u1ebfn t\u1ed1i \u01b0u hi\u1ec7u su\u1ea5t WordPress,\u00a0 c\u00f3 nhi\u1ec1u c\u00e2u h\u1ecfi li\u00ean quan t\u1edbi c\u00e1ch xo\u00e1 Query\u00a0 Strings t\u1eeb Static Resources (lo\u1ea1i b\u1ecf c\u00e1c chu\u1ed7i s\u1ed1 truy v\u1ea5n kh\u1ecfi file t\u0129nh). C\u00e1c t\u1ec7p CSS v\u00e0 JavaScript c\u1ee7a b\u1ea1n th\u01b0\u1eddng c\u00f3 \u0111i k\u00e8m phi\u00ean b\u1ea3n t\u1ec7p \u1edf cu\u1ed1i URL, ch\u1eb3ng h\u1ea1n nh\u01b0 :<\/span><\/p>\n<pre>domain.com\/style.css?ver=4.6<\/pre>\n<p>&nbsp;<\/p>\n<p><span>B\u1eb1ng c\u00e1ch lo\u1ea1i b\u1ecf ph\u1ea7n \u0111u\u1ed5i n\u00e0y c\u00f3 th\u1ec3 c\u1ea3i thi\u1ec7n b\u1ed9 nh\u1edb \u0111\u1ec7m c\u1ee7a b\u1ea1n. Gi\u00fap b\u1ea1n xo\u00e1 c\u1ea3nh b\u00e1o t\u1eeb c\u00e1c tool nh\u01b0 l\u00e0\u00a0 <\/span><span>GTMetrix<\/span><span>\u00a0\u00a0v\u00e0\u00a0\u00a0<\/span><span>Pingdom<\/span><span> .<\/span><img decoding=\"async\" class=\"size-full wp-image-40351\" src=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/04\/remove-query-strings-from-static-resources-2.png\" sizes=\"(max-width: 1908px) 100vw, 1908px\" srcset=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/04\/remove-query-strings-from-static-resources-2.png 1908w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/04\/1_remove-query-strings-from-static-resources-2-300x98.png 300w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/04\/1_remove-query-strings-from-static-resources-2-768x251.png 768w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/04\/1_remove-query-strings-from-static-resources-2-1024x335.png 1024w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/04\/remove-query-strings-from-static-resources-2-610x199.png 610w\" alt=\"X\u00f3a chu\u1ed7i truy v\u1ea5n kh\u1ecfi t\u00e0i nguy\u00ean t\u0129nh\" width=\"1908\" height=\"624\" title=\"\"><\/p>\n<div id=\"attachment_40351\" class=\"wp-caption aligncenter\">\n<p class=\"wp-caption-text\">Query Strings t\u1eeb Static Resources<\/p>\n<\/div>\n<p><span>B\u1ea1n l\u01b0u \u00fd, c\u00e1c <\/span><strong><span>chu\u1ed7i truy v\u1ea5n th\u01b0\u1eddng <\/span><\/strong>\u0111\u01b0\u1ee3c \u0111\u01b0a ra l\u00e0 c\u00f3 nguy\u00ean nh\u00e2n c\u1ea3, Ng\u01b0\u1eddi ta th\u01b0\u1eddng th\u00eam <span>Phi\u00ean b\u1ea3n ph\u00eda sau v\u00ed \u0111\u1ec3 ch\u1ec9 \u0111\u1ecbnh s\u1ef1 thay \u0111\u1ed5i v\u00ed d\u1ee5 \u1edf \u0111\u00e2y l\u00e0 s\u1ef1 thay \u0111\u1ed5i file <strong>style.css<\/strong>:<\/span><\/p>\n<pre>style.css?ver=4.6<\/pre>\n<p>th\u00e0nh<\/p>\n<pre>style.css?ver=4.7<\/pre>\n<p><span>M\u1ed7i \u0111\u01b0\u1eddng d\u1eabn tr\u00ean l\u00e0 m\u1ed9t url ho\u00e0n to\u00e0n m\u1edbi ,\u00a0 N\u1ebfu b\u1ea1n chu\u1ed7i ph\u00eda sau th\u00ec khi truy c\u1eadp trang c\u00f3 th\u1ec3 website s\u1ebd l\u1ea5y l\u1ea1i url c\u0169 b\u1ecb cache kh\u00f4ng ph\u1ea3i url m\u1edbi , \u0111i\u1ec1u n\u00e0y c\u00f3 th\u1ec3 l\u00e0m h\u1ecfng giao di\u1ec7n website. Ngo\u00e0i ra vi\u1ec7c \u0111\u1ecbnh danh nh\u01b0 tr\u00ean c\u0169ng gi\u00fap cho ng\u01b0\u1eddi dung, nh\u00e0 ph\u00e1t tri\u1ec3n d\u1ec5 theo d\u00f5i \u0111\u00e1nh d\u1ea5u c\u1ed9t m\u1ed1c thay \u0111\u1ed5i phi\u00ean b\u1ea3n.<\/span><\/p>\n<h3 id=\"C\u00e1ch_x\u00f3a_Query_Strings_t\u1eeb_Static_Resources_trong_WordPress_b\u1eb1ng_c\u00e1ch_th\u00eam_m\u00e3.\">C\u00e1ch x\u00f3a Query Strings t\u1eeb Static Resources trong WordPress b\u1eb1ng c\u00e1ch th\u00eam m\u00e3.<\/h3>\n<p><span>B\u1ea1n c\u00f3 th\u1ec3 d\u1ec5 d\u00e0ng x\u00f3a c\u00e1c chu\u1ed7i truy v\u1ea5n kh\u1ecfi website c\u1ee7a m\u00ecnh b\u1eb1ng m\u1ed9t v\u00e0i d\u00f2ng m\u00e3. Ch\u1ec9 c\u1ea7n th\u00eam ph\u1ea7n sau v\u00e0o file:<\/span><code>functions.php<\/code> <span>tr\u00ean theme WordPress c\u1ee7a b\u1ea1n .<\/span><\/p>\n<pre class=\"  language-php\"><code class=\"  language-php\"><span class=\"token keyword\">function<\/span> <span class=\"token function\">remove_query_strings<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span>\r\n   <span class=\"token keyword\">if<\/span><span class=\"token punctuation\">(<\/span><span class=\"token operator\">!<\/span><span class=\"token function\">is_admin<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span>\r\n       <span class=\"token function\">add_filter<\/span><span class=\"token punctuation\">(<\/span><span class=\"token single-quoted-string string\">'script_loader_src'<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token single-quoted-string string\">'remove_query_strings_split'<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">15<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>\r\n       <span class=\"token function\">add_filter<\/span><span class=\"token punctuation\">(<\/span><span class=\"token single-quoted-string string\">'style_loader_src'<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token single-quoted-string string\">'remove_query_strings_split'<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">15<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>\r\n   <span class=\"token punctuation\">}<\/span>\r\n<span class=\"token punctuation\">}<\/span>\r\n\r\n<span class=\"token keyword\">function<\/span> <span class=\"token function\">remove_query_strings_split<\/span><span class=\"token punctuation\">(<\/span><span class=\"token variable\">$src<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">{<\/span>\r\n   <span class=\"token variable\">$output<\/span> <span class=\"token operator\">=<\/span> <span class=\"token function\">preg_split<\/span><span class=\"token punctuation\">(<\/span><span class=\"token double-quoted-string string\">\"\/(&amp;ver|\\?ver)\/\"<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token variable\">$src<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>\r\n   <span class=\"token keyword\">return<\/span> <span class=\"token variable\">$output<\/span><span class=\"token punctuation\">[<\/span><span class=\"token number\">0<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">;<\/span>\r\n<span class=\"token punctuation\">}<\/span>\r\n<span class=\"token function\">add_action<\/span><span class=\"token punctuation\">(<\/span><span class=\"token single-quoted-string string\">'init'<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token single-quoted-string string\">'remove_query_strings'<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/code><\/pre>\n<div id=\"attachment_40352\" class=\"wp-caption aligncenter\"><img decoding=\"async\" class=\"size-full wp-image-40352\" src=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/04\/remove-query-strings-code-snippet.png\" sizes=\"(max-width: 1548px) 100vw, 1548px\" srcset=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/04\/remove-query-strings-code-snippet.png 1548w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/04\/1_remove-query-strings-code-snippet-300x180.png 300w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/04\/1_remove-query-strings-code-snippet-768x460.png 768w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/04\/1_remove-query-strings-code-snippet-1024x614.png 1024w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/04\/remove-query-strings-code-snippet-610x366.png 610w\" alt=\"X\u00f3a \u0111o\u1ea1n m\u00e3 truy v\u1ea5n\" width=\"1548\" height=\"928\" title=\"\"><\/div>\n<p class=\"wp-caption-text\">Sau \u0111\u00f3 b\u1ea1n l\u01b0u l\u1ea1i v\u00e0 ki\u1ec3m tra .<\/p>\n<p>&nbsp;<\/p>\n<h4 id=\"H\u00ecnh_\u1ea3nh_v\u00ed_d\u1ee5_th\u1ef1c_t\u1ebf.\"><span>H\u00ecnh \u1ea3nh v\u00ed d\u1ee5 th\u1ef1c t\u1ebf.<\/span><span id=\"with-query-strings-before-code\" class=\"anchor-hash\" aria-hidden=\"true\"><\/span><\/h4>\n<p><span>Tr\u01b0\u1edbc khi xo\u00e1:<\/span><\/p>\n<div id=\"attachment_40353\" class=\"wp-caption aligncenter\"><img decoding=\"async\" class=\"size-full wp-image-40353\" src=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/04\/query-strings.png\" sizes=\"(max-width: 1474px) 100vw, 1474px\" srcset=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/04\/query-strings.png 1474w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/04\/1_query-strings-300x129.png 300w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/04\/1_query-strings-768x331.png 768w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/04\/1_query-strings-1024x442.png 1024w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/04\/query-strings-610x263.png 610w\" alt=\"Y\u00eau c\u1ea7u c\u00f3 chu\u1ed7i truy v\u1ea5n\" width=\"1474\" height=\"636\" title=\"\"><\/div>\n<div><\/div>\n<h4 id=\"Sau_khi_xo\u00e1_v\u00e0_kh\u00f4ng_c\u00f2n_chu\u1ed7i_truy_v\u1ea5n.\">Sau khi xo\u00e1 v\u00e0 kh\u00f4ng c\u00f2n chu\u1ed7i truy v\u1ea5n.<\/h4>\n<div id=\"attachment_40354\" class=\"wp-caption aligncenter\"><img decoding=\"async\" class=\"size-full wp-image-40354\" src=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/04\/no-query-strings.png\" sizes=\"(max-width: 1466px) 100vw, 1466px\" srcset=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/04\/no-query-strings.png 1466w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/04\/1_no-query-strings-300x131.png 300w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/04\/1_no-query-strings-768x335.png 768w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/04\/1_no-query-strings-1024x447.png 1024w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/04\/no-query-strings-610x266.png 610w\" alt=\"Y\u00eau c\u1ea7u kh\u00f4ng c\u00f3 chu\u1ed7i truy v\u1ea5n\" width=\"1466\" height=\"640\" title=\"\"><\/p>\n<p class=\"wp-caption-text\">\n<\/div>\n<h3 id=\"C\u00e1ch_x\u00f3a_Query_Strings_t\u1eeb_Static_Resources_trong_WordPress_b\u1eb1ng_c\u00e1ch_s\u1eed_d\u1ee5ng_plugins\">C\u00e1ch x\u00f3a Query Strings t\u1eeb Static Resources trong WordPress b\u1eb1ng c\u00e1ch s\u1eed d\u1ee5ng plugins<\/h3>\n<p>&nbsp;<\/p>\n<p>M\u1ed9t c\u00e1ch kh\u00e1c, b\u1ea1n c\u00f3 th\u1ec3 d\u00f9ng plugin `Perfmatters` tr\u1ea3 ph\u00ed, sau khi c\u00e0i \u0111\u1eb7t v\u00e0 k\u00edch ho\u1ea1t plugin, b\u1ea1n c\u00f3 th\u1ec3 truy c\u1eadp v\u00e0o giao di\u1ec7n plugin v\u00e0 b\u1eadt t\u00ednh n\u0103ng n\u00e0y l\u00ean.<\/p>\n<p><img decoding=\"async\" class=\"size-full wp-image-40355\" style=\"font-size: 13px;\" src=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/04\/perfmatters-remove-query-strings-1.png\" sizes=\"(max-width: 1476px) 100vw, 1476px\" srcset=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/04\/perfmatters-remove-query-strings-1.png 1476w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/04\/1_perfmatters-remove-query-strings-1-300x194.png 300w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/04\/1_perfmatters-remove-query-strings-1-768x497.png 768w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/04\/1_perfmatters-remove-query-strings-1-1024x663.png 1024w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/04\/perfmatters-remove-query-strings-1-610x395.png 610w\" alt=\"X\u00f3a chu\u1ed7i truy v\u1ea5n b\u1eb1ng plugin Perfmatters\" width=\"1476\" height=\"956\" title=\"\"><\/p>\n<div id=\"attachment_40355\" class=\"wp-caption aligncenter\">\n<p class=\"wp-caption-text\"><span>X\u00f3a chu\u1ed7i truy v\u1ea5n b\u1eb1ng plugin Perfmatters<\/span><\/p>\n<\/div>\n<h2 id=\"Kh\u00f4ng_c\u00f3_chu\u1ed7i_truy_v\u1ea5n_n\u00e0o_n\u1eefa\"><span>Kh\u00f4ng c\u00f3 chu\u1ed7i truy v\u1ea5n n\u00e0o n\u1eefa<\/span><span id=\"no-more-query-strings\" class=\"anchor-hash\" aria-hidden=\"true\"><\/span><\/h2>\n<p><span>Sau khi s\u1eed d\u1ee5ng c\u00e1c c\u00e1ch tr\u00ean b\u1ea1n c\u00f3 th\u1ec3 qu\u00e9t l\u1ea1i website b\u1eb1ng tool GTMetrix ho\u1eb7c Pingdom s\u1ebd kh\u00f4ng c\u00f2n nh\u1eadn \u0111\u01b0\u1ee3c c\u1ea3nh b\u00e1o n\u1eefa.<\/span><\/p>\n<div id=\"attachment_40356\" class=\"wp-caption aligncenter\"><img decoding=\"async\" class=\"size-full wp-image-40356\" src=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/04\/remove-query-strings-from-static-resources-warning-1.png\" sizes=\"(max-width: 1882px) 100vw, 1882px\" srcset=\"https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/04\/remove-query-strings-from-static-resources-warning-1.png 1882w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/04\/1_remove-query-strings-from-static-resources-warning-1-300x41.png 300w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/04\/1_remove-query-strings-from-static-resources-warning-1-768x104.png 768w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/04\/1_remove-query-strings-from-static-resources-warning-1-1024x139.png 1024w, https:\/\/tino.vn\/blog\/wp-content\/uploads\/2020\/04\/remove-query-strings-from-static-resources-warning-1-610x83.png 610w\" alt=\"\u0110\u00e3 s\u1eeda l\u1ed7i x\u00f3a chu\u1ed7i truy v\u1ea5n kh\u1ecfi c\u1ea3nh b\u00e1o t\u00e0i nguy\u00ean t\u0129nh\" width=\"1882\" height=\"256\" title=\"\"><\/div>\n<div>Ch\u00fac c\u00e1c b\u1ea1n th\u00e0nh c\u00f4ng.!<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Khi n\u00f3i \u0111\u1ebfn t\u1ed1i \u01b0u hi\u1ec7u su\u1ea5t WordPress,\u00a0 c\u00f3 nhi\u1ec1u c\u00e2u h\u1ecfi li\u00ean quan t\u1edbi c\u00e1ch xo\u00e1 Query\u00a0 Strings t\u1eeb Static Resources (lo\u1ea1i b\u1ecf c\u00e1c chu\u1ed7i s\u1ed1 truy v\u1ea5n kh\u1ecfi file t\u0129nh). C\u00e1c t\u1ec7p CSS v\u00e0 JavaScript c\u1ee7a b\u1ea1n th\u01b0\u1eddng c\u00f3 \u0111i k\u00e8m phi\u00ean b\u1ea3n t\u1ec7p \u1edf cu\u1ed1i URL, ch\u1eb3ng h\u1ea1n nh\u01b0 : domain.com\/style.css?ver=4.6 &nbsp; [&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-4920","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\/4920","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=4920"}],"version-history":[{"count":0,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/ht_kb\/4920\/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=4920"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/tags?post=4920"},{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/tino.vn\/blog\/wp-json\/wp\/v2\/ht_kb_category?post=4920"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}