Last active
February 24, 2022 17:52
-
-
Save Asikur22/1aebfd4f981c7e539a2c010412ba1da8 to your computer and use it in GitHub Desktop.
[CSS/JS/Image Cache Busting] #DisableCache #dev
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Change img src for disable img cache. | |
* @TODO remove on Production. | |
*/ | |
function wpse_84670_time_as_img_version($src) { | |
$src[0] = add_query_arg('dummy', time(), $src[0]); | |
return $src; | |
} | |
add_filter('wp_get_attachment_image_src', 'wpse_84670_time_as_img_version'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Disable CSS/JS Cache | |
*/ | |
function wpse_84670_time_as_version( $url ) { | |
if ( strpos( $url, 'fonts.googleapis.com' ) !== false || strpos( $url, 'font-awesome' ) !== false ) { | |
return $url; | |
} | |
return add_query_arg( array( 'ver' => time() ), $url ); | |
} | |
add_filter( 'script_loader_src', 'wpse_84670_time_as_version' ); | |
add_filter( 'style_loader_src', 'wpse_84670_time_as_version' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Disable CSS/JS Cache | |
*/ | |
function wpse_84670_time_as_version( $url ) { | |
return add_query_arg( array( 'ver' => time() ), $url ); | |
} | |
add_filter( 'script_loader_src', 'wpse_84670_time_as_version' ); | |
add_filter( 'style_loader_src', 'wpse_84670_time_as_version' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment