Last active
June 6, 2018 20:07
-
-
Save mediaformat/18f19a9313361fb8a2b7112bb31f6490 to your computer and use it in GitHub Desktop.
Poor man's CSS cache busting in WP
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
<?php | |
function wp_scripts() { | |
//Internal cache tracking | |
wp_enqueue_style( 'theme-style', get_stylesheet_directory_uri() . '/style.css', array(), filemtime( get_stylesheet_directory() .'/style.css' ), 'all' ); | |
//External cache tracking | |
wp_enqueue_style( 'global-styles', 'https://example-assets.com/css/global_styles.css', array(), strtotime( wp_remote_retrieve_header( wp_remote_get( 'https://example-assets.com/css/global_styles.css'), 'last-modified' ) ) ); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment