Should we have hashes in our asset file names? #3
ampersarnie
started this conversation in
General
Replies: 1 comment 1 reply
-
i haven't found it necessary to cache bust in this way in a long time. i set my asset version numbers from the theme/plugin (shown below), and haven't experienced issues with caching (including on sites running behind cloudflare, on which assets have year-long cache timeouts). // theme
add_action( 'wp_enqueue_scripts', function (): void {
$theme = wp_get_theme();
wp_enqueue_script( 'theme', 'https://domain.tld/path/to/file.js', [], $theme->get( 'Version' ), true );
} );
// plugin
add_action( 'wp_enqueue_scripts', function (): void {
$plugin = get_plugin_data( __FILE__, false, false );
wp_enqueue_script( 'plugin', plugins_url( '/path/to/file.js', __FILE__ ), [], $plugin['Version'], true );
} ); |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
It's briefly mentioned in the current
README.md
that assets have hashes appended to them. I may need to get into this a little more (quick and dry is this was implemented as VIP don't recommendfilemtime()
for version cache busting), but I was wondering if anyone had any thoughts on this. It may be a non-issue if we implement a config as discussed here that allows for removal.Beta Was this translation helpful? Give feedback.
All reactions