Whenever the core.js file changes on the server a new query string value is generated. That allows browsers to cache the file as long as the file does not change on the server.
Today I got the question if it is possible to utilize the same method for custom js and css files. The answer is yes.
SharePoint provides the functionality to generate browser cache save Urls for such files if they reside inside the _layouts directory or one of it’s localized subdirectory using the following method:
public static string Microsoft.SharePoint.Utilities.SPUtility.MakeBrowserCacheSafeLayoutsUrl(string name, bool localizable)
The first parameter needs to be the filename without a path (e.g. test.css) the second defines if the file resides in a language specific subdirectory or directly in the _layouts directory.
The following code will (e.g.) create the output below for german locale:
string saveUrl = Microsoft.SharePoint.Utilities.SPUtility.MakeBrowserCacheSafeLayoutsUrl("my-own.js", true);