Because query strings are part of the cache key when the file is cached on the CDN, in many cases it's simplest to reference the file with a changed
?version query parameter. This behavior is automatic when providing the
$version parameter to the
wp_enqueue_script( 'my-theme', get_stylesheet_uri(), , '2019-05-4-1' );
This will enqueue and output a
<script> tag with a URL appended with
?ver=2019-05-4-1. Every time the
style.css is changed, the
$version parameter needs to be updated.
$version parameter can be defined dynamically, though should be optimized to only change when the file has changed. To reduce disk IO, you should not read the file at runtime to generate a version, such as
md5_file. Using Webpack or other build-time workflows to build assets on deploy will provide unique filenames that can provide hard coded values.