How To Disable Salesforce Lightning Component Caching

Wes
SalesTrip
Published in
2 min readMay 18, 2018

Salesforce optimises the production runtime performance by caching components in the client. This is awesome for the end users as page loads are l̶i̶g̶h̶t̶n̶i̶n̶g̶ very fast. This is a lot less awesome for developers when developing lightning components — at worst you may think your code is wrong, at best you have to hit hard refresh a few times while you wait for the cache to clear.

Luckily, you can fix this via config but you need to do it in two places i.e.

1. Session Caching

Click through Setup > Session Settings > Caching and deselectEnable secure and persistent browser caching to improve performance.

Note that this is an Org-wide setting.

2. Debug Mode

Click through Setup > Custom Code > Lightning Component > Debug Mode, then check the box next to your user and click Enable.

Auto-disable Component Caching in Scratch Orgs

If you’re lucky enough to be using DX you can configure your Scratch Org config files so that Lightning component caching is disable as new Scratch Orgs are spun up — pretty damn cool right? All you need to do is include the S1EncryptedStoragePref2 to thedisabled array under orgPreferences:

Hopefully that’ll save you a few hours over the year. Do not do this in Prod as caching optimises performance (and you shouldn’t be developing or testing in Prod)✌🏼

--

--

Wes
SalesTrip

Technology Executive, currently CTO @ SalesTrip.