I am working on the CSS of my wordpress site. When I make changes and refresh the page the changes are not reflected. When I clear the browser history and cache the changes are still reflected. When I view the source code of the page and look at the css file it has the old content before the change. How do I get this to update so I can develop?
Add a random version number at the end of the css file you are attaching. If you are using 'wp_enqueue_style' or wp_register_style functions, pass a random (version) number
rand(111,9999) to 4th parameter. If you are attaching css as an html tag, you should add "
?ver=<?php echo rand(111,999)?>" at the end of the file name. Examples are here
wp_register_style( 'custom-style', get_template_directory_uri() . '/css/custom-style.css', array(), rand(111,9999), 'all' );
<link rel="stylesheet" type="text/css" href="http://website.com/css/custom-style.css?ver=<?php echo rand(111,999)?>">
It will avoid caching on client end caching and possibly server caching too.
I know this post is over a year old but I thought I would mention that CloudFlare caches static files such as css, js and images to aid in faster loading times. Something I just took hours to figure out, since I was having issues with my css changes not reflecting on reloading. CloudFlare has Development mode that you can enable for 3hrs. If you forget to enable it before you start making modifications then you can purge cache from cloudflare management.
It is possible that your host is using something like Varnish to cache your site's output. I ran into this with a client's site hosted on a cut-rate shared hosting account. The only remedy I found was to just be patient.
If you are using a child theme, its possible that you need to enqueue the child theme stylesheet in order to see the changes immediately. This solved my issue.
Just want to point out - be sure to be mindful of any caching plugins that you have installed. WP Fastest Cache, for example, can create this problem if you don't remember to log into the WP dashboard and click on "Clear Cache --> Delete Cache and Minified CSS / JS" up in the nav menu.
This maybe old. But I need to support someone who may looking for a help. I had the same problem and I checked my plugins. There was "w3 total cache" plugin that speedsup loading. That is server side cache plugin so I disabled it. The css changes are visible again realtime. There are lot of loading booster plugins. So check your plugin list and disable them until you finish the development.