[SalesForce] How to ensure that a non-cached version of external script will be loaded using in Lightning Components

As described here

http://docs.releasenotes.salesforce.com/en-us/spring15/release-notes/rn_lightning_load_resources.htm

you can load external JS or CSS files (stored as static resources) like this

<ltng:require 
    scripts="/resource/jsLibOne,/resource/jsLibTwo"
    styles="/resource/cssOne,/resource/cssTwo" 
/>

However if you update jsLibOne for instance, the chances are high that you will end up witch a cached version.

This never happened in Visualforce using e.g.

<apex:includeScript value="{!$Resource.jsLibOne}"/>

How can it be enforced, that the current version is loaded regardless of any cachings?

It is very dangerous to assume that for users clearing the browser's cache could be a solution. During development time this is nothing more than a burden. But after the component is in the wild, you can't ensure that it runs with the current versions of libraries which might be crucial even for data integrity. It's even pretty sure that the user will run obsolete code.

Extension 1:

I found in the documentation that ltng:require also takes care that the same library referenced across multiple components in an app will be loaded only once. I'm looking for answers that do not breaks this or ensure this, too.

Best Answer

As of Summer '16 you can use the $Resource global in Lightning:

<ltng:require scripts="$Resource.<resource name>" />

For archived resources:

<ltng:require scripts="$Resource.<resource name> + '/js/script.js'" />

And use join() for multiple resources:

<ltng:require styles="{!join(',', 
                      $Resource.SLDS090 + '/assets/styles/salesforce-lightning-design-system-ltng.css', 
                      $Resource.font_awesome + '/font-awesome-4.4.0/css/font-awesome.min.css',
                      $Resource.ionicons + '/ionicons-2.0.1/css/ionicons.min.css')}"/>

A timestamp will be automatically added so you don't need to generate your own numbers anymore.