[SalesForce] How to refresh Static Resource JS file in Lightning Component

I am trying to build a Lightning Component, and have referenced external JS library functions via Static Resource. But since I'm in development currently, the JS functions file is being modified heavily, but the Preview Mode of Lightning Component App, is not refreshing the updated JS file.

The static resource is a Zip file, and with every function change I reupload the static resource and call the updated function in Javascript Controller. But it does not reflect the changes in the preview. How can I sort this out, this is troubling and consuming most of my time.

Best Answer

Usually the static resource files are cached in the browser. So in case you make minor change in the files they are not reflected immediately.

So to always get the latest changes in the browser, you can either do Ctrl+F5 or update VF page with the verison number in the resource.

Before Change:

<script type="text/javascript" src="{!URLFOR($Resource.myStaticResource, 'myApp/js/sequenceOrder.js')}"></script>

after Change:

<script type="text/javascript" src="{!URLFOR($Resource.myStaticResource, 'myApp/js/sequenceOrder.js?ver=001')}"></script>

Just increment the version in the parameter and that will fetch the changes in the view. I haven't worked with Lightning components, but this what works out for me in VF.