Avada Cache Buster

I use the Avada theme on some of my WordPress sites. However, when I update the style the browser continues using the cached version. To solve this, I wrote a little script to go in the child theme functions.php.

It changes Fusion’s CSS version to the time the folder was last modified, causing the browser to go and fetch the new file.

add_filter( 'style_loader_src', 'update_css_ver', 9999, 2 );

function update_css_ver( $src ) {
if ( strpos( $src, 'fusion' ) ) {
$src = remove_query_arg( 'ver', $src );
$upload_dir = wp_upload_dir();
$upload_dir2 = trailingslashit( $upload_dir['basedir'] );
$lastupdate = filemtime( $upload_dir2 . 'fusion-styles/' );
$src = ($src . '?' . $lastupdate );
return $src;

Leave a Reply