Same Server Connect in Layout and Content Page Running Twice

Hello!
Hope you all are well. Just quickly I’m still new overall.

I am trying to understand how I would reuse the state/data between my layout/page and page/partials from server connect/database query.

Im testing with data ill need on nearly every page/partial (example different currencies, order statuses and so on from postgreSql database). What i want is to not make calls every load (use cache) but when i do need to make a query, only send one query not multiple for same data.

So on layout page, I did a server connect to get this database query, and then I am caching it in local storage (1hour). then I can access that information in layout page easily (via the server connect schema).

However I get confused when I want to access same information in a content page/partial.
I assumed I needed to create another local storage on the content page (same id as the other one on layout page, so they should access same data), but I cant reference the data directly from the local storage as I don’t know the schema. So I created exactly same server connect action on that partial page, so I can access it in server connect available data.

Now this generally works, example the data is cached, for future page loads. However the initial page load, its making two calls for same data (which makes sense) but this will cause shitty first page speeds when i have a lot more calls to make. I assume my overall management of data is wrong, but I’m not too sure how to do it, nor cant find too much information on this.

Two calls:

The main method that is coming to mind is manually settings up a schema on the local storage on each page for that data that will be cached in local storage. Is there a simpler way to managing schema across pages/partials?

Would appreciate anyones help. Data management is my biggest area where i need to improve in wappler. In bubble.io it wasn’t ideal, very restrictive but it always presented you with what data should be available, is there a overall workflow process that i should be following in wappler to achieve something similar.

Hi Hinky,

Any components you create on layout page, are available to be used directly in all content pages that are under that layout page.
For partial, it doesn’t really work like that. You can setup manual bindings in code view, but you have to know what you are doing to get it to work.

For your case at the moment, you don’t have to create SC on content page. If the dynamic data picker is not showing the layout page data, either the content-layout linking is messed up, or there is a bug in Wappler.

Please check if you can see a “meta” tag with ac:route in content page. There should be just one. Usually this has been known to cause picker issues.

Also, to recheck, you can just create a new project with default NodeJS setup, and see if you can find layout page components in content page picker.

1 Like

yes you are completely right. My bad, I jumped the gun and added the same components in the content page, and was getting confused when I should of just restarted wappler.
thank you very much @sid, sorry for question