Nir Frank
Nir Frank

Reputation: 3

Why are my style.css updates reflected only when performing a hard refresh, reverting to a previous version when refreshing afterwards?

Long title, sorry. Anyway:

I've got a WordPress site with a custom theme and its child theme. For a while, updating the child theme's style.css would produce results as expected - a refresh (or hard-refresh) of the website, and it would work from then on out.

Now, however, my updates are only reflected when I hard-refresh a certain page. If I then refresh the same page, or navigate to a different page on which the changes should be applied, the changes are reverted and the old style.css file is called instead.

I am using, and have tried purging all the caches available through the "W3 Total Cache" plugin. I have tried disabling "W3 Total Cache" entirely and installing the "Style.css Load Last Version" plugin, which as far as I know is using this trick to always call for the latest style.css file. I've tried visiting the page using incognito mode. In all cases, the behavior is the same - hard refresh works as a one-time deal, either refreshing the same page or navigating to different parts of the site which should be effected results in the browser calling for an older style.css file version and the changes are reverted.

Long test, sorry :) Anyway, I would love some feedback on this issue as its driving me nuts.

Upvotes: 0

Views: 961

Answers (1)

Yamu
Yamu

Reputation: 1662

Which method are you using to load your child-theme's css file?? If you are using a link to include your child css as

<link rel="" ..............> then try appending the version at the end of you file name 

<link rel="stylesheed"...... href="your_child_style.css?v-=1.10"> where ?v=1.10 is the version number. Every time you update your css increase the version number(In case you don't want to change the version every time i suggest you use the php time() function to generate a unique number eveytime the css is loaded)

If your css file is loaded automatically then make sure you have version decalared in you css file as

/*
Theme Name: yourchildtheme
Version: 1.2

*/

Try to change the version and it will work just fine. Good luck

add_action( 'wp_enqueue_scripts', 'my_child_theme_scripts' );
function my_child_theme_scripts() {
 wp_enqueue_style( 'parent-theme-css', get_template_directory_uri() . '/style.css' );
}

Upvotes: 1

Related Questions