{"id":232652,"date":"2023-01-26T12:43:00","date_gmt":"2023-01-26T09:43:00","guid":{"rendered":"https:\/\/wordpress.mediadoma.com\/?p=232652"},"modified":"2023-01-26T12:46:41","modified_gmt":"2023-01-26T09:46:41","slug":"hur-beraettar-man-foer-webblaesare-om-att-uppdatera-css-js-filer-naer-filer-aendras-i-wordpress","status":"publish","type":"post","link":"https:\/\/wordpress.mediadoma.com\/sv\/hur-beraettar-man-foer-webblaesare-om-att-uppdatera-css-js-filer-naer-filer-aendras-i-wordpress\/","title":{"rendered":"Hur ber\u00e4ttar man f\u00f6r webbl\u00e4sare om att uppdatera CSS\/JS-filer n\u00e4r filer \u00e4ndras i WordPress?"},"content":{"rendered":"<p>I <a href=\"https:\/\/wordpress.mediadoma.com\/sv\/php-skript-foer-att-saekra-wordpress-mapparna-genom-att-staella-in-korrekta-filbehoerigheter\/\" title=\"wordpress-\">wordpress-<\/a> rubriker m\u00e4rker du f\u00f6rmodligen att de statiska <a href=\"https:\/\/helloacm.com\/css-for-image-onmouseover-event\/\" target=\"_blank\" rel=\"noopener nofollow\" class=\"external external_icon\">CSS-<\/a> och <a href=\"https:\/\/helloacm.com\/tutorial-example-how-to-access-microsoft-excel-chart-using-the-windows-scripting-host-jscript\/\" target=\"_blank\" rel=\"noopener nofollow\" class=\"external external_icon\">JS<\/a> -tillg\u00e5ngarna h\u00e4nvisas till s\u00e5 h\u00e4r:<\/p>\n<pre><code>https:\/\/justyy.com\/wp-content\/themes\/twentytwelve\/style.css?ver=4.4.2<\/code><\/pre>\n<p>Fr\u00e5gestr\u00e4ngen <strong>?ver=<\/strong> anv\u00e4nds f\u00f6r att tala om f\u00f6r webbl\u00e4sare att g\u00f6ra en forcerad uppdatering av de statiska resurserna n\u00e4r wordpress k\u00e4rnversion har \u00e4ndrats eftersom vissa webbl\u00e4sare kanske inte kan ignorera cachefilerna eftersom URL:en inte har \u00e4ndrats.<\/p>\n<p>Ibland vill jag \u00e4ndra <strong>style.css<\/strong> i <a href=\"https:\/\/helloacm.com\/schema-2-0-dont-let-google-penalize-your-slow-loading-website\/\" target=\"_blank\" rel=\"noopener nofollow\" class=\"external external_icon\">barntemat<\/a> men webbl\u00e4saren h\u00e4mtar fortfarande den cachade filen eftersom wordpress-versionen inte har \u00e4ndrats. och jag m\u00e5ste g\u00e5 till <a href=\"https:\/\/helloacm.com\/cloudflare-weaker-sha1-ssl-to-support-all-browsers\/\" target=\"_blank\" rel=\"noopener nofollow\" class=\"external external_icon\">CloudFlare<\/a> f\u00f6r att rensa cachen. En b\u00e4ttre l\u00f6sning \u00e4r att \u00e4ndra <strong>?ver=<\/strong> till <strong>?filetime=<\/strong> s\u00e5 att varje g\u00e5ng filen har \u00e4ndrats \u00e4ndras URL:en.<\/p>\n<p>Du kan l\u00e4gga till f\u00f6ljande i mallen f\u00f6r barntema functions.php f\u00f6r att f\u00e5 detta att h\u00e4nda.<\/p>\n<pre><code>function justyy_remove_cssjs_ver( $src) {\n\u00a0 $newsrc = $src;\n\u00a0 if( strpos( $newsrc, '?ver=')) {\n\u00a0 \u00a0 $newsrc = remove_query_arg( 'ver', $newsrc );\n\u00a0 }\n\u00a0 $rootdir = '\/var\/www'; \/\/ the path to your domain on the server\n\u00a0 $url = parse_url($newsrc, PHP_URL_PATH);\n\u00a0 $source = $rootdir .'\/'. $url;\n\u00a0 if (is_file($source)) {\n\u00a0 \u00a0 $newsrc .= \"?m=\".filemtime($source);\n\u00a0 \u00a0 return $newsrc;\n\u00a0 } \u00a0 \u00a0 \n\u00a0 return $src; \/\/ keep unchanged if file is not accessible.\n}\nadd_filter( 'style_loader_src', 'justyy_remove_cssjs_ver', 10, 2 );\nadd_filter( 'script_loader_src', 'justyy_remove_cssjs_ver', 10, 2 );<\/code><\/pre>\n<p>Du kan anv\u00e4nda <a href=\"https:\/\/helloacm.com\/file_put_contents-substitute-in-php\/\" target=\"_blank\" rel=\"noopener nofollow\" class=\"external external_icon\">filinneh\u00e5ll<\/a>.<\/p>\n<p><div id=\"PostUnique_PostSource\" style=\"padding-top: 50px\">Inspelningsk\u00e4lla:  <a target=\"_blank\" rel=\"noopener nofollow\" href=\"\/\/helloacm.com\" class=\"external external_icon\">helloacm.com<\/a><\/div><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hur ber\u00e4ttar man f\u00f6r webbl\u00e4sare att uppdatera CSS\/JS-filer p\u00e5 nytt n\u00e4r filer \u00e4ndras i WordPress?<\/p>\n","protected":false},"author":1,"featured_media":223973,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_wp_rev_ctl_limit":""},"categories":[838,848,901,922,807,724,1092,868],"tags":[1173],"class_list":["post-232652","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-guide-foer-nyboerjare","category-handledningar","category-koda","category-oevrig","category-php-9","category-utvecklaren","category-webbplatshastighet","category-wordpress-9","tag-affiai-sv"],"_links":{"self":[{"href":"https:\/\/wordpress.mediadoma.com\/sv\/wp-json\/wp\/v2\/posts\/232652","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.mediadoma.com\/sv\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wordpress.mediadoma.com\/sv\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/sv\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/sv\/wp-json\/wp\/v2\/comments?post=232652"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.mediadoma.com\/sv\/wp-json\/wp\/v2\/posts\/232652\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/sv\/wp-json\/wp\/v2\/media\/223973"}],"wp:attachment":[{"href":"https:\/\/wordpress.mediadoma.com\/sv\/wp-json\/wp\/v2\/media?parent=232652"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/sv\/wp-json\/wp\/v2\/categories?post=232652"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wordpress.mediadoma.com\/sv\/wp-json\/wp\/v2\/tags?post=232652"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}