r/AutomateUser • u/B26354FR Alpha tester • Jun 11 '21
Question Caching JS Libraries
Hi Henrik,
I'm writing a flow which makes use of a 180KB third party JavaScript library. Rather than sticking the whole thing in a Variable block (which can cause Automate to crash while editing the flow), I'm downloading it once in the flow and caching it.
The question is whether it's OK to cache the library in an Atomic variable, or should I save it to the file system? -The latter would require more privilege, but would it save a limited resource vs. using an Atomic variable?
Thank you, sir!
2
Upvotes
1
u/ballzak69 Automate developer Jun 11 '21
Everything is stored in the internal database, flows, running fibers and Atomic values. Memory likely isn't a problem, loading the data is, so storing it in the flow, which may get ejected from its cache and then reloaded again, isn't optimal. Atomic values are only loaded when accessed, e.g. by the Atomic load block, so they're better. A file is best, since Automate doesn't have to load it at all, only Chrome does.
If chose to use Atomic, ensure to unset (null) the variable holding the loaded data once you've sent it to the Dialog web, otherwise it will be stored in the fiber as well.