As mentioned in several other answers, you want to have a unique identifier for your static assets based on the content, that is, the identifier changes if and only if the content changes. Thus, browsers can still use the cached version of the resource until the content has changed - this is exactly what you want. This method is called the static asset version.
Therefore, do not use the current time or a random number / string. If you can, use either the file modification time or the (better) hash of the md5 file of its contents. You can add this identifier to the query string (which will be ignored) or ( better ) add it to the file name before the extension.
To counter this and eliminate confusion in the busting caching method mentioned in some other answers: cache busting is a method used by advertisers to force the browser to always reload the property so that the advertiser can measure the number of ad impressions by the number of resource requests. This is easy to do using a random number. Usually you do not want to use this for your static assets.
source share