snnsnn
Explore posts from serversHow does `query` cache actually work?
In Solid, because of the reactivity, changing route unloads the current component and loads the next one. This means whatever you did in the current route will be discarded. In other words, if you fetch the data for the next route, it will be discarded as well. The query function is a solution this problem. It store the data so that it won't be fetched again when the current route changes.
The preload function will be associated with the corresponding route, and it will be called by the router component to fetch the data for that route. So, no need to check for
Preload function will be triggered when the user hovers over the link pointing to that route, assuming Router's preload prop is set to true. You can manually call the preload function, it will work the same. Sole purpose of the preload function is to fetch the data for the route. So, you should wrap the server function in a query and call it, otherwise the data you fetch will be discarded and fetched again when the route's component loads. That is why the value is cached for a short period of time. On the server side, query function store the queried value for the duration of a request. That way, if a query calls another query, the value will be fetched once. The data is stored on the rotuer. The request path is nothing to do with caching. Hope this clarifies your confusion.
location.pathname
as it is designed to run when the path matches.Preload function will be triggered when the user hovers over the link pointing to that route, assuming Router's preload prop is set to true. You can manually call the preload function, it will work the same. Sole purpose of the preload function is to fetch the data for the route. So, you should wrap the server function in a query and call it, otherwise the data you fetch will be discarded and fetched again when the route's component loads. That is why the value is cached for a short period of time. On the server side, query function store the queried value for the duration of a request. That way, if a query calls another query, the value will be fetched once. The data is stored on the rotuer. The request path is nothing to do with caching. Hope this clarifies your confusion.
16 replies
Seeking Insights on SolidStart Server Function Issue
Thank you so much for your help in debugging the issue. Your explanation about how the server utilizes multiple workers for various capabilities really clarified the problem. It seems that the "Update value using Server Function" created an entirely new store in a different worker and updated that.
Reflecting on the issue I opened, it is the textbook definition of data inconsistency across multiple workers. The docs should emphasize this behavior. Reading directly from a file and writing to it solved the issue. Turns out it’s not only that—the failing of the revalidation call after API updates was also tied to this issue. With the new logic, this now works as expected. Probably, revalidation was working as expected but was using the stale data.
I wonder what the source of this behavior is—Nitro maybe? It would be great if they discussed the underlying architecture more or provided guidance to help people avoid running into these kinds of issues, saving time and frustration.
7 replies
Registering API Endpoints on SolidStart
Thanks, I know the event object has request, repsonse etc, but i am asking if there is a way to match a route, and parse query parameters, as I am trying to avoid external dependencies and manual work, and I see h3 router is not exposed: https://h3.unjs.io/guide/router
3 replies
CDCloudflare Developers
•Created by snnsnn on 8/19/2024 in #pages-help
Do middlewares are counted as functions?
Ok, thanks.
9 replies
CDCloudflare Developers
•Created by snnsnn on 8/19/2024 in #pages-help
Do middlewares are counted as functions?
I just realized I left out the most important detail. I was using
functions/_middleware.js
and that is the only middleware I use, so everything counts as function invocation, right?9 replies
CDCloudflare Developers
•Created by snnsnn on 8/19/2024 in #pages-help
Do middlewares are counted as functions?
I was using it as an easy way to detect static assets, I can remove it. So, without it, there should be no cost then. For example:
9 replies
CDCloudflare Developers
•Created by snnsnn on 8/19/2024 in #pages-help
Do middlewares are counted as functions?
Without the middleware, I receive 404 for anything, including static assets.
9 replies
CDCloudflare Developers
•Created by snnsnn on 8/19/2024 in #pages-help
Do middlewares are counted as functions?
I can not use a static index.html as I need to generate its content dynamically. I don't know how to serve it without a middleware.
9 replies
How to keep/reuse DOM elements across routes?
You can create your element in a seperate root, https://www.solidjs.com/docs/latest/api#createroot it wont get disposed.
14 replies
Context not working as expected
Here is a detailed explanation on how context works: https://stackoverflow.com/a/74492899/7134134
15 replies