“wp_enqueue_style();” don’t load new edited style

First, sorry my english. I am using Local by flywheel to manager my site files and my wordpress version is 4.9.4.

Here is the problem, When I use

 wp_enqueue_style('wharever', get_stylesheet_uri());

To load style.css at the first time with a just simple content inside:

body { color: orange; }

Everything is just fine, and we have a page with everything in orange text, but when I change the style.css body color to green (or whatever), they just don’t change, and always are orange.

PS.: in wp_enqueue_style, I changed the version parameter and he changes, but only at the first time and stuck with the first color I put for the version that was put.

If this is a feature of wordpress, how can I turn this off? This don’t see quite useful know that we can’t change style.css at will just to test without change version.

3 Answers
3

Another solution is to use filemtime for the cachebusting, so that the last modified timestamp is used as the querystring variable.

This has the advantage that of still using the browser cache, and yet, a new file is served when the file is actually changed because the querystring changes. eg.

$lastmodtime= filemtime(get_stylesheet_directory().'/style.css');
wp_enqueue_style('whatever', get_stylesheet_uri(), array(), $lastmodtime);

Leave a Comment