Replies: 8 comments 2 replies
-
I assume you are talking about datums. From my personal experience, an alternative is retruning 404 if a datum hash can not be resolved (I.e. on blockfrost). Personally I find this a much worse user experience than 200+null, because you can effectively not distinguish between putting a wrong URI, other mistakes, or a valid response where no resolution was found BTW stupid suggestion: If you can decide to not cache non-200, can you also not cache null? |
Beta Was this translation helpful? Give feedback.
-
That's correct. We're querying for a specific datum on Kupo, it's not yet on-chain, so it returns a 200 "null." Our caching system (HAproxy) detects that the answer was valid (200) and caches it. Next time we try that same datum, which might now be on-chain, our caching system doesn't know that it should request again, as it believes that "null" was a valid answer. The solution, I believe, would be for Kupo to return any other API feedback, rather than 200 as it has been now. |
Beta Was this translation helpful? Give feedback.
-
Also, for additional context, this is what HAProxy caches: https://www.haproxy.com/documentation/hapee/latest/configuration/config-sections/cache/, and the conditions within which it caches. Ideally, null responses would not return a 200 code, simply to avoid caching. |
Beta Was this translation helpful? Give feedback.
-
Hey Conrad, beside the 200+null issue, for all the other 200, is the content immutable right? So they should be able to be safely cached? |
Beta Was this translation helpful? Give feedback.
-
Hey @nemo83, as far as I know, yes. |
Beta Was this translation helpful? Give feedback.
-
Content is actually NOT immutable; it's a blockchain. It's only eventually immutable. There's a section of the documentation which goes deeper into this explanation. All-in-all, Kupo provides a ETag as part of every response (including and in particular HEAD requests). For a same URI, a same ETag means that responses are identical. Clients can use the If-None-Match request header to ask only responses that differ from a previous point. This is a relatively standard way of providing caching through HTTP and I would recommend to use it. In the end, there's nothing wrong from an HTTP standpoint when fetching a a datum that doesn't exist. Hence why the answer is 200 despite the resource being null. Returning 404 in that case would make it impossible to distinguish from a genuinely wrong URI. |
Beta Was this translation helpful? Give feedback.
-
Thanks both, it makes sense. |
Beta Was this translation helpful? Give feedback.
-
Just encountered this behaviour. However, the behaviour seems inconsistent. For some datum hash queries, it returns For example, in current preprod, I can run
which returns However, when altering the datum hash to something like As a user, I would expect the behaviour to be consistent. |
Beta Was this translation helpful? Give feedback.
-
Hello Team,
Is it normal for "null" queries to be delivered as OK 200?
On our side, we are trying to cache Kupo requests, so that we can take load off of Kupo for repetitive queries. However, some requests return "null" as a 200 OK response, which results in "null" being stored in our cache.
Would it be possible for Kupo to return any other value, other than 200, for all "null" responses, so that we could cache only 200 responses?
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions