The simplest way of informing browser about a file modification is to change its name. This can be done by adding “ver” parameter to the filename. You can then increment the version number each time you want to force download a file. You can do it like this:
Force cached stylesheet to refresh:
<link href="http://sumtips.com/style.css?ver=2" rel="stylesheet" type="text/css" media="screen" />
Force cached static files to refresh:
<link rel="shortcut icon" href="http://sumtips.com/favicon.ico?ver=2" />
You can add anything after the ‘?’ to force refresh files.
Automatically Using PHP
Updating version info manually each time may become tedious. To automate the process, we can use PHP to add the parameter:
Now whenever the file is changed on the server, its modified time is added to filename. This lets the browser know that the file has changed and it downloads a new copy.
wp_enqueue_style( 'theme_style', 'style.css', '', time() ); wp_enqueue_script( 'theme_script', 'script.js', '', time() );
Hope it helps!