knockout / knockout

Knockout makes it easier to create rich, responsive UIs with JavaScript
http://knockoutjs.com/
Other
10.43k stars 1.52k forks source link

Feature Request: Allow for cache disabling as a configuration option or parameter to knockout components #2583

Open strommj opened 2 years ago

strommj commented 2 years ago

I maintain an unconventional application, where our code is rendered many times within an iframe with different data each render. Because of this, using components within this space is also non-conventional, causing old data to be cached with the initial registering of the component on the first render.

clearing the component cache didn't work (is this a bug?), and I had to un-register the component before re-registering it (each time our app is rendered with new data).

My request, since the standard of unregistering a component before registering seems like a bad habit, is to have an option to disable caching for any such component registration. This could be an extra parameter (ko.components.register('foo', true)) or it could be an app level config. Either way, I think there are enough people concerned about the forceful caching of view model data as noted here.

That, or perhaps the nature of this request falls under the notion of allowing dynamic data within the component declaration. By nature, disabling the cache solves this problem as long as the app has some other mechanism to refresh on data changes. However, it seems the component design was oriented towards data that doesn't change, but maybe you have a better idea in mind to solve this.

Regards, Matt