40

In many cases I've seen that LE is not displaying recent changes made in Setup immediately like in Salesforce Classic, but somehow cached or delayed. Yesterday I found an easy and perfectly reproducible scenario and I want to ask why this is happening and how to enforce a real and total refresh flushing every possible cache.

Example Scenario (please do NOT provide workarounds for this - emphasis is on EXAMPLE ONLY)

I was showing a client how Field Level Security (FLS) works. My example was to hide a field going to: Setup(Classic) > Customize > Accounts > Fields and scroll there down and pick any existing custom field (as an example). Now on the field-view press the button [Set Field-Level-Security] and remove all checkboxes in the "Visible"-column. Press Save. Verify the result on any Account record view.

Expected result in Aloha (Salesforce Classic):

On Aloha the impact is immediately: removing checkboxes hides the field after doing a page-refresh (F5). Checking all the boxes again make the field show-up after the next F5 fully as expected. Fine!

Delayed impact in Lightning Experience:

But not so in LE! First F5 is a huge roundtrip and you can say "Hi" to the snowman again. Back on the record page the field is still displayed. Cross-Check in Aloha: the field is already invisible as expected. Now waiting for a time eventually seems to make it disappear - but I was not able to do it fast and not predictable. Sometimes it took seconds, sometimes minutes. This is a no-go for fancy Admin-Tasks: please figure more complex examples, where you have to (quickly!) verify settings e.g. for several different profiles.

Questions:

  • why this is happening? I'm sure this is a kind of cache and designed as a feature (and is no bug). I want to understand the technical backgrounds (deeply).
  • how can I enforce to flush all caches and make 100% sure, that all obsolete data is reloaded freshly from the server?
  • is there an option to disable that cache either for the Org completely, or for profiles, or for certain users?

What I've tried so far:

  • clear browser cache ==> no impact, still obsolete stuff will be shown
  • clear local storage ==> no impact, still obsolete stuff will be shown
  • clear session storage ==> no impact, still obsolete stuff will be shown

Conclusion:

Now I'm running out of ideas. The response seems to be cached sever-side, where my local flushes can't reach. The result is re-sending "dirty" data on-and-on until something "unknown" happens and the response is eventually updated. Personally I don't like that feature at all, but I'm sure for many users there are good reasons to turn it OFF selectively from time to time.

  • 1
    Have you tried changing the value of the timestamp (t) parameter in the url and re-submitting the url? When working with lightning components I have experienced the cache getting sort of "stuck" before on an old version of my component and changing this value to a greater value would cause the newest version to be fetched on page reload. I am not sure how reliable this is though and it may not impact the the whole cache. – dsharrison Oct 24 '16 at 16:58
  • This sound VERY similar to one of the demos I saw during this webinar. developer.salesforce.com/events/webinars/BuildAppsFaster There seemed to be a lot of forward looking statements, but I think that when Lightning Data Service is GA this might not be an issue anymore. – John Thompson Oct 28 '16 at 23:39
29

Actually, this problem is due to the "aggressive" caching setting in LEX. Go to Setup Home > Security > Session Settings. Uncheck the option: Enable secure and persistent browser caching to improve performance. That should make it such that only a single page reload gives you new data/settings/etc.

Disabled cache

  • 2
    Welcome to SFSE, Greg! Great to see you on our corner of the interwebs! :) – Adrian Larson Oct 31 '16 at 16:00
  • Thanks Greg, it seems to work! Is there anything to read about that cache-mechanism happening in the background? I mean technically how, when and why the cache works? Dough Chasman told me once or twice about such things, but I really can't remember much of it... – Uwe Heim Nov 3 '16 at 9:21
  • Is it possible to disable this setting when spinning up a fresh scratch org? Is this option available in the scratch org json? It'd sure be nice if we didn't have to go into setup and disable this every time we spin up a new scratch org. – Tim Lewis Dec 27 '17 at 15:27
  • After a little searching I see there's a enableCacheAndAutocomplete - Indicates whether the user’s browser is allowed to store user names and auto-fill the User Name field on the login page (true) or not (false). on developer.salesforce.com/docs/atlas.en-us.api_meta.meta/… but that looks like it only applies to the first checkbox under the "Caching" heading, and it's also not clear whether that option is availalbe in the scratch org json or if it would require a subsequent call to the Metadata API to toggle it. – Tim Lewis Dec 27 '17 at 15:35
6

To disable the setting mentioned in Greg's answer for scratch orgs, disable S1EncryptedStoragePref2 in your project scratch def JSON:

config/project-scratch-def.json

{
    "orgName": "My Scratch Org",
    "edition": "Developer",
    "orgPreferences": {
        "enabled": [
            "S1DesktopEnabled"
        ],
        "disabled": [
            "ChatterEnabled",
            "S1EncryptedStoragePref2"
        ]
    }
}

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.