2

I have a lwc component with apex service wired. This apex service takes an parameter. Since it is a wired service, I need to mark it as Cacheable=true on the apex controller.

On the UI

  1. Wired service with parameter 'x' runs and Service returns 10 records.
  2. Server side some changes happened and now there are 12 records on server for 'x' parameter
  3. Now when the wired service runs again, it still gives me only 10 records.

If I wait for some time and refresh the entire browser, I get 12 records. Is this expected behavior with wired service?

1 Answer 1

5

Yes, this is expected behaviour. There is a (time-limited) client-side cache used to avoid invoking the server when the cacheable method invocation parameters match those for which a cache entry exists.

If you don't want this, switch to imperative apex calls to uncacheable methods, or use the refreshApex feature to flush the cache for a given wire response.

1
  • Thank you!. I believe we need to use wire and refreshapex in conjunction to get the benefits Feb 5, 2020 at 19:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .