admin管理员组文章数量:1130349
I have been struggling with a site that I inherited from another developer.
My main problem is that, changes I make in the css file of the template don't get picked up right away, indicating that some kind of caching is kicking in. What I checked is.
- The .htaccess file for any caching directive.
- Any caching WordPress plugins that might be activated.
- Any caching functionality implemented by the hoster.
- Cloudflare or any other CDN.
- [EDIT] I have tried different browsers and computers so the caching is server side.
As you can imagine none of the above is enabled and yet my changes to the css take some hours to be seen.
I am not a WordPress expert in any way, so I am asking the community of what other caching mechanism I might missing here.
Thanks
I have been struggling with a site that I inherited from another developer.
My main problem is that, changes I make in the css file of the template don't get picked up right away, indicating that some kind of caching is kicking in. What I checked is.
- The .htaccess file for any caching directive.
- Any caching WordPress plugins that might be activated.
- Any caching functionality implemented by the hoster.
- Cloudflare or any other CDN.
- [EDIT] I have tried different browsers and computers so the caching is server side.
As you can imagine none of the above is enabled and yet my changes to the css take some hours to be seen.
I am not a WordPress expert in any way, so I am asking the community of what other caching mechanism I might missing here.
Thanks
Share Improve this question edited Nov 15, 2018 at 11:56 pierostz asked Nov 15, 2018 at 11:19 pierostzpierostz 1033 bronze badges 7 | Show 2 more comments1 Answer
Reset to default 1You could change the file version each time the file gets updated. To do this, go to your functions.php file and find where the style-sheet is being enqueued (or registered) - it will look something like:
wp_enqueue_style( 'theme-style', get_template_directory_uri() . '/style.css' );
and change it to:
wp_enqueue_style( 'theme-style', get_template_directory_uri() . '/style.css', array(), filemtime( get_template_directory_uri() . '/style.css' ) );
This will change the file version each time you save it, forcing the new version to get loaded.
As you very correctly pointed out, the styles have to be properly added in functions.php, not hard-coded in header.php or elsewhere.
I have been struggling with a site that I inherited from another developer.
My main problem is that, changes I make in the css file of the template don't get picked up right away, indicating that some kind of caching is kicking in. What I checked is.
- The .htaccess file for any caching directive.
- Any caching WordPress plugins that might be activated.
- Any caching functionality implemented by the hoster.
- Cloudflare or any other CDN.
- [EDIT] I have tried different browsers and computers so the caching is server side.
As you can imagine none of the above is enabled and yet my changes to the css take some hours to be seen.
I am not a WordPress expert in any way, so I am asking the community of what other caching mechanism I might missing here.
Thanks
I have been struggling with a site that I inherited from another developer.
My main problem is that, changes I make in the css file of the template don't get picked up right away, indicating that some kind of caching is kicking in. What I checked is.
- The .htaccess file for any caching directive.
- Any caching WordPress plugins that might be activated.
- Any caching functionality implemented by the hoster.
- Cloudflare or any other CDN.
- [EDIT] I have tried different browsers and computers so the caching is server side.
As you can imagine none of the above is enabled and yet my changes to the css take some hours to be seen.
I am not a WordPress expert in any way, so I am asking the community of what other caching mechanism I might missing here.
Thanks
Share Improve this question edited Nov 15, 2018 at 11:56 pierostz asked Nov 15, 2018 at 11:19 pierostzpierostz 1033 bronze badges 7- It's likely just your browser. Do you see the changes if you use a different browser, or use private browsing? – Jacob Peattie Commented Nov 15, 2018 at 11:49
- I should have pointed that out. I tried different browsers, computers and all. The caching is server side. – pierostz Commented Nov 15, 2018 at 11:55
- So what file are you editing exactly? Just style.css, or something else? – Jacob Peattie Commented Nov 15, 2018 at 12:51
- style.css located in my theme folder. I am sure that is the one used for styling through Developers Tools, therefore the changes I make there are visible after a while – pierostz Commented Nov 15, 2018 at 15:25
-
You could change the file version each time the file gets updated. To do this, go to your functions.php file and find where the style-sheet is being enqueued (or registered) - it will look something like
wp_enqueue_style( 'theme-style', get_template_directory_uri() . '/style.css' );and change it towp_enqueue_style( 'theme-style', get_template_directory_uri() . '/style.css', array(), filemtime( get_template_directory_uri() . '/style.css' ) );. This will change the file version each time you save it, forcing the new version to get loaded. – Bob Commented Nov 16, 2018 at 10:59
1 Answer
Reset to default 1You could change the file version each time the file gets updated. To do this, go to your functions.php file and find where the style-sheet is being enqueued (or registered) - it will look something like:
wp_enqueue_style( 'theme-style', get_template_directory_uri() . '/style.css' );
and change it to:
wp_enqueue_style( 'theme-style', get_template_directory_uri() . '/style.css', array(), filemtime( get_template_directory_uri() . '/style.css' ) );
This will change the file version each time you save it, forcing the new version to get loaded.
As you very correctly pointed out, the styles have to be properly added in functions.php, not hard-coded in header.php or elsewhere.
本文标签: theme developmentWhich cache is kicking
版权声明:本文标题:theme development - Which cache is kicking 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749169712a2326792.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


wp_enqueue_style( 'theme-style', get_template_directory_uri() . '/style.css' );and change it towp_enqueue_style( 'theme-style', get_template_directory_uri() . '/style.css', array(), filemtime( get_template_directory_uri() . '/style.css' ) );. This will change the file version each time you save it, forcing the new version to get loaded. – Bob Commented Nov 16, 2018 at 10:59