Weird CSS Caching Issue With Beaver Builder Theme Solved

Spread the love

This post is mostly for me, so I can remember what to do if I need to solve a css caching issue in the future. Oddly, with the Word Press BB-Theme, I’ve experienced caching with the style.css file on one particular website. I was baffled at why updates to the file were not appearing. I did all the usual things including clearing cache, clearing Cloudflare cache, browser cache… and none of that worked.

It turned out that someone had modified the child theme at some point including both the classes/class-fl-child-theme.php file and the functions.php file which may or may not have contributed to the problem. Restoring them to the originals seemed to help, but once again today, changes to the style.css file refused to show up and the old version was continuing to be loaded in browsers.

Something about the theme seems to stop WordPress from knowing about changes to the style.css file. After doing some googling, I found a solution:

Removing/commenting out this from functions.php:

add_action( ‘wp_enqueue_scripts’, ‘FLChildTheme::enqueue_scripts’, 1000 );

and substituting it with:

function enqueue_bb_child_theme_style() {
wp_enqueue_style( ‘fl-child-theme’, FL_CHILD_THEME_URL . ‘/style.css’, array(), wp_get_theme()->get(‘Version’) );
}
add_action( ‘wp_enqueue_scripts’, ‘enqueue_bb_child_theme_style’, 1000 );

means browsers will most likely get the latest version as long as you update the version number of the style.css file when it’s changed.

This worked for me.

I cannot take credit for this fix however, it belongs to Brian Hogg.

Thank you Brian!

Hopefully I’ll remember this fix if I run across another website with the same issue. So, leaving the solution here, and perhaps it will help others if they don’t come across Brian’s solution.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top