11

I'm developing a Quick Action Lightning Component that is delivered stand-alone, and I'm finding that it's hard to force the browser to refresh the component and ensure that the latest version is being rendered before I test a change.

I can't find any reference in the documentation on how to do this, but...

Can you force the refresh of a Lightning Component's source code when testing it?

If so - how?

4 Answers 4

23

In Salesforce Setup, go to Security > Session Settings. In the Caching section, uncheck "Enable secure and persistent browser caching to improve performance".

This is the right setting during development to make sure that the changes you make to your component take effect immediately and that you are not served a cached version of the component.

1
  • Worked first time. You're a genius! Mar 9, 2017 at 14:07
3

If you do not have dependencies defined in the Application bundle then Lightning will not check for changes. In that case I found prior to Spring '17 it took 3 refreshes of the browser to get the updated version.

After Spring '17 I refresh the browser twice upon making changes when no dependency is defined.

If a dependency is defined then the browser will detect it and refresh automatically

7
  • 1
    Thanks for that - it may prove helpful, but I'm not using an app bundle - In this particular case I have a single component that is used in a quick action that I'm developing - so I'm not sure where I would define the dependency. Mar 2, 2017 at 16:17
  • (question edited to reflect) Mar 2, 2017 at 16:20
  • 1
    @RobBaillie you can't so u will have to refresh twice to be sure
    – Eric
    Mar 2, 2017 at 17:09
  • :-) URGH - so much to love ;-) Mar 2, 2017 at 17:13
  • 1
    Yeah. Not sure if my way is correct or not but it works for me
    – Eric
    Mar 2, 2017 at 17:14
2

If you're using Chrome, there's an extension called clear cache that will do what you want. You click on it and it clears the cache so the latest version of your component will load when you refresh the page since it will no longer be in the cache. It also will automatically force a refresh of the page for you when you click on it.

4
  • Thanks for the tip, though I'm finding that this isn't reliably refreshing the component. Odd. Mar 3, 2017 at 9:42
  • 1
    I'm surprised to hear that. It's what we were taught in the Salesforce University DEV-601 Lightning Components Training Course. It's always worked well for me. You can also clear the cache from the Dev Console using Chrome Developer Tools. Are you certain you've saved all the changes to your component before refreshing?
    – crmprogdev
    Mar 3, 2017 at 13:42
  • I'll add that as @Eric posted, it's always a good idea where possible to encapsulate your component within another component or component app bundle for testing.
    – crmprogdev
    Mar 3, 2017 at 13:45
  • 100%, yes it's being saved before navigating to the page. Tip on @Eric noted, thanks. Mar 3, 2017 at 14:01
0

I can't get it to always work on one refresh, but I have a way to always get it to refresh in two (better than nothing...).

For me, using Chrome:

  1. Find Application tab in Dev Console

  2. On the leftsidebar, find Storage -> IndexedDB. Expand it.

  3. Right click ComponentDefStorage and select Refresh IndexedDB.

  4. Refresh browser 2x

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.