Update Template On Set Schedule, Cache Results

Is there a way to have a template updated once, then for calls following the initial load just return the same data?

I am attempting to have a schedule kick off at 12am, gather data then update the said template. When other calls to the http end point are called, I would like to just have that cache data returned. Super new to node red, sorry if this question is super basic.



Hi @Majerus1223

Good question. The Template node itself cannot cache results, but you can use Context in order to do this.

This recipe in the cookbook shows the basic principle - https://cookbook.nodered.org/http/include-data-from-another-flow

You can store the data returned by the Widget Data node in Context using a Change node.

You can then either update the Template node to retrieve values from Context (check its sidebar help for how to do that), or you could add a Change node ahead of it to get the data from Context and copy it back onto the message where the Template node expects it to be.

1 Like

Thanks for the fast response, ill give this a shot.

This solution worked perfectly! Thanks!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.