Changes to CSS don't happen instantly after refresh / hard refresh

Bug Summary

I’ve been using local for over a year now and it’s a wonderful product, however since the last week every time I make any change to a CSS file it doesn’t reflect in the website I’m building. I have to refresh / hard refresh 5 times or more for it to work. This is beyond frustrating.

I enqueue my stylesheets with filemtime PHP function so it always uses the latest version of my css.

Steps to reproduce

Create a new local instance, create a theme, add the basic files (index.php, functions.php, and style.css). Enqueue your stylesheet and use wp_head and wp_footer respectively.

This is my enqueue function:

function gdc_enqueue_styles() {
    $stylesheet_uri = get_template_directory_uri() . '/style.css';
    $version = filemtime(get_template_directory() . '/style.css');

    wp_enqueue_style('gdc-main-stylesheet', $stylesheet_uri, array(), $version);
}

add_action('wp_enqueue_scripts', 'gdc_enqueue_styles');

This is what has worked for me for the past year and all of a sudden it just doesn’t work any more.

Environment Info

I’m using Windows 10

I use the default environment

My localWP version is: Version 9.0.3+6684

Hi @josefsalazar

Have you tried setting this into your wp-config?

define( 'WP_DEVELOPMENT_MODE', 'theme' );

Hey, thanks for the quick reply.

I did add that but it didn’t solve it.

Any other ideas? I’ve been browsing the forums and all the other questions similar to mine are way too old to apply

Is this a child theme to a parent? Or just it’s own custom theme?

Aside from your theme do you have any other plugins on the site that could be interfering? Builder plugins for example like Elementor have CSS Regeneration options that need to be flushed as well.

1 Like