Skip to content

Instantly share code, notes, and snippets.

@mediaformat
Last active June 6, 2018 20:07
Show Gist options
  • Save mediaformat/18f19a9313361fb8a2b7112bb31f6490 to your computer and use it in GitHub Desktop.
Save mediaformat/18f19a9313361fb8a2b7112bb31f6490 to your computer and use it in GitHub Desktop.
Poor man's CSS cache busting in WP
<?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