In SharePoint we can use the layouts folder to place the images/css/js files so that it can cache for 365 days(default settings of IIS pointing to the layouts folder), this has advantage that it can cache the files for 365 days. But sometimes we can modify the files at that time we need to ensure that the client browser must read the updated file instead of serving from the local browser cache (of client machine)
This can be achieved by developing a small piece of custom code (probably a user control and refer it in the master page). This usercontrol will get some property of the file (css/js) and we can use the SPUtility.MakeBrowserCacheSafeLayoutsUrl(“filename.ext”,false). And we can use a literal control to generate the appropriate tags.
This basically generate a url like http://websitename/_layouts/filename.ext?rev=MlFHGUOJpQLunJnOWiGaog%3D%3D
The querystring rev will be generated based on the timestamp of the file and append to the filename.ext, so that everytime the new copy of the file is posted the token will be generated freshly.
Note: We need to do IIS reset to make sure that the new token will be generated otherwise the old token will be served from the server.