Caching #103
-
I'm not sure how to make use of the caching functions, could you elaborate on it with examples? Could this help bigger apps with lots of listeners run smoother? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
The caching feature is mostly used to reduce network traffic between the JS client and the Live plugin. Basically, the JS client keeps a local cache of the most recent responses and with each request sends a hash of the last response it knows. If the hash of the response the Live plugin would send matches the one the client sent, the plugin just sends a response telling the JS client that nothing has changed since the last time this value was requested. This is similar to how caching works in HTTP: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag This mostly makes sense for large objects, like a list of all clips on a track or a list of all browser items in a given category, that would take a few MB to be sent across the network, but it doesn't solve performance issues inside of Live unfortunately, and it doesn't apply to listeners. Regarding listeners, ableton-js already deduplicates listeners on any given object, so that if you attach the same listener to the same object multiple times in the JS client, it will only be attached once in Live to improve performance. I hope this helps! Let me know if you have any further questions regarding this topic! |
Beta Was this translation helpful? Give feedback.
Yeah, you don't have to worry about it in your script. If you want to have more control over the cache, you can pass
cacheOptions
to theAbletonJS
instance. You can also access the cache usingableton.cache
if you'd like to see what it contains or modify its contents.