I’ve a WordPress web site with medium-level visitors, ~10,000 distinctive guests a day. Arround 30% of my each day guests are recurrent. I always make some UI enhancements: colours, font-size, javascript UX components and so forth. Subsequently on the identical day, I can change .js and .css possibly 2 or 3 occasions. The issue is: the recurring guests are viewing cached variations of the css/javascript information).
I’ve discovered this actual helpful script:
perform my_load_scripts($hook) {
// create my very own model codes
$my_js_ver = date("ymd-Gis", filemtime( plugin_dir_path( __FILE__ ) . 'js/customized.js' ));
$my_css_ver = date("ymd-Gis", filemtime( plugin_dir_path( __FILE__ ) . 'model.css' ));
//
wp_enqueue_script( 'custom_js', plugins_url( 'js/customized.js', __FILE__ ), array(), $my_js_ver );
wp_register_style( 'my_css', plugins_url( 'model.css', __FILE__ ), false, $my_css_ver );
wp_enqueue_style ( 'my_css' );
}
add_action('wp_enqueue_scripts', 'my_load_scripts');
It will make a versioning title primarily based on the day the file its created, however I am afraid to place it in public, as a result of it’ll run everytime a consumer go to the web site. And I am afraid that the server can run out of sources.
Do you may have one other methodology?