# Are Flows Stored In A Cache?

**URL:** <https://discourse.nodered.org/t/are-flows-stored-in-a-cache/80582>\
**Category:** General\
**Created:** [15 August 2023 13:52 UTC](https://discourse.nodered.org/t/are-flows-stored-in-a-cache/80582 "2023-08-15T13:52:39Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Light2K95](https://avatars.discourse-cdn.com/v4/letter/l/df705f/32.png) [@Light2K95](https://discourse.nodered.org/u/Light2K95)\
**Post date:** [15 August 2023 13:52 UTC](https://discourse.nodered.org/t/are-flows-stored-in-a-cache/80582/1 "2023-08-15T13:52:39Z")

</div>

Hello,  
I've been using a MongoDB collection instead of local flow.json file to store flows in Node Red. My problem is that when I change the flows in the database manually, changes doesn't reflect to editor. Despite the fact It makes another GET request for flows.

This is the same when using the local flows.json. If I delete a debug node from my local flow.json file, I still see it in the editor when I hit refresh. But if I make the changes before instantiating a Node Red instance, changes are reflected in the editor.

My questions is that once the Node Red runtime is started does it make a request and store the response in some kind of cache and use it until the flow is deployed? If so, how can I disable the said cache or make node-red read from database again, just like when first initiated, everytime I hit refresh on my browser?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [15 August 2023 13:59 UTC](https://discourse.nodered.org/t/are-flows-stored-in-a-cache/80582/2 "2023-08-15T13:59:21Z")

</div>

flows are not cached (or rather not like you think)

They are loaded into the Node-RED runtime (server side) at startup.

When the client (browser) requests the flows via the API, they are returned from the running server (i.e. from the runtime that was created on startup ~ from the flows JSON).

So you can call it cached but in reality, you are actually getting a JSON representation of the running flows - NOT the flows stored on disk (or in database). That distinction is important.

---

<div class="post-metadata">

**Author:** ![Light2K95](https://avatars.discourse-cdn.com/v4/letter/l/df705f/32.png) [@Light2K95](https://discourse.nodered.org/u/Light2K95)\
**Post date:** [15 August 2023 14:17 UTC](https://discourse.nodered.org/t/are-flows-stored-in-a-cache/80582/3 "2023-08-15T14:17:06Z")

</div>

Is there any way to overwrite the representation from the running server without restarting it again? Couldn't the client call the same API it used during instantiation? I couldn't manage to find an API in the DOCS which gets called in the case of refreshing.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [15 August 2023 14:55 UTC](https://discourse.nodered.org/t/are-flows-stored-in-a-cache/80582/4 "2023-08-15T14:55:32Z")

</div>

> [@Light2K95](#):
>
> Is there any way to overwrite the representation from the running server without restarting it again?

Yes\*. This is what happens when you do a **full** deploy. The API is documented here: [POST /flows : Node-RED](https://nodered.org/docs/api/admin/methods/post/flows/)

`*` Yes to not restarting the whole node-red service **but** the deploying of flows WILL cause the runtime to destroy all running nodes and re-instantiate them - thats what happens when you deploy.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [15 August 2023 15:04 UTC](https://discourse.nodered.org/t/are-flows-stored-in-a-cache/80582/5 "2023-08-15T15:04:31Z")

</div>

> [@Light2K95](#):
>
> Is there any way to overwrite the representation from the running server without restarting it again?

Using the API endpoint that @Steve-Mcl has pointed you at - but use the `reload` value for the `Node-RED-Deployment-Type` header. This will tell the runtime to reload the flow configuration from storage.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [15 August 2023 15:09 UTC](https://discourse.nodered.org/t/are-flows-stored-in-a-cache/80582/6 "2023-08-15T15:09:15Z")

</div>

Apologies, Nick is correct, use the `reload` header to reload flows from manually edited DB entry.

NOTE: To be clear - this will still restart the runtime (i.e. nodes will be destroyed and re-instantiated from the flows JSON in the database)

---

<div class="post-metadata">

**Author:** ![Light2K95](https://avatars.discourse-cdn.com/v4/letter/l/df705f/32.png) [@Light2K95](https://discourse.nodered.org/u/Light2K95)\
**Post date:** [16 August 2023 05:25 UTC](https://discourse.nodered.org/t/are-flows-stored-in-a-cache/80582/7 "2023-08-16T05:25:31Z")

</div>

I should edit the post function in flows.js which is inside the editor-api/lib/admin directory right?

---

<div class="post-metadata">

**Author:** ![Light2K95](https://avatars.discourse-cdn.com/v4/letter/l/df705f/32.png) [@Light2K95](https://discourse.nodered.org/u/Light2K95)\
**Post date:** [16 August 2023 05:46 UTC](https://discourse.nodered.org/t/are-flows-stored-in-a-cache/80582/8 "2023-08-16T05:46:11Z")

</div>

Shouldn't I use GET/ flows? When I refresh the browser I can only see GET requests made. POSTs only happen when I hit deploy. I want flows.json to be re-read when I refresh the page. Alternatively I might use HTTP request node to change the active flow. Which API should i use in that case?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [16 August 2023 07:00 UTC](https://discourse.nodered.org/t/are-flows-stored-in-a-cache/80582/9 "2023-08-16T07:00:35Z")

</div>

> [@Light2K95](#):
>
> I should edit the post function in flows.js which is inside the editor-api/lib/admin directory

For what reason? There should be no reason to edit source code of the core application to perform actions.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [16 August 2023 07:03 UTC](https://discourse.nodered.org/t/are-flows-stored-in-a-cache/80582/10 "2023-08-16T07:03:31Z")

</div>

> [@Light2K95](#):
>
> I want flows.json to be re-read when I refresh the page.

If you modified the source code to make that happen, you would effectively be restarting the runtime every time.

---

<div class="post-metadata">

**Author:** ![Light2K95](https://avatars.discourse-cdn.com/v4/letter/l/df705f/32.png) [@Light2K95](https://discourse.nodered.org/u/Light2K95)\
**Post date:** [16 August 2023 11:09 UTC](https://discourse.nodered.org/t/are-flows-stored-in-a-cache/80582/11 "2023-08-16T11:09:07Z")

</div>

I thought I had to override methods in source code since I wanted NODE-RED to behave that way all the time. But open further thinking, I am just making post requests from an outer source, since I might need the original functionality of the program in the future. That solved my problem, thank you.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [30 August 2023 11:09 UTC](https://discourse.nodered.org/t/are-flows-stored-in-a-cache/80582/12 "2023-08-30T11:09:19Z")

</div>

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