4 ms·
So like the server bringing you a glass of water and basket of bread that you may or may not want, but most people do so the odds are good enough.
by jaxn 9y ago
So like the server bringing you a glass of water and basket of bread that you may or may not want, but most people do so the odds are good enough.
- brian_cloutier 9y agothe parent was implying that the server might later change their mind and ask for the water and bread back, so you shouldn't do anything irreversible with it.
- csours 9y agoIn the interest of clobbering the analogy even further: It would be like the server bringing you a red wine and then serving fish - the red wine doesn't go with it, so you better hope you can get it off the table and the taste out of your mouth.
- eitland 9y agoOK, since we are into analogies: A recipe with a shopping list. Only you get the shopping list first and some of the items might be for another recipe (and you might already have them.)
- rusk 9y agoi.e. only idempotent operations, such as GET. You should not perform a POST using the information obtained in these hints. Perhaps an alternative analogy is branch prediction? Browser is permitted to run along a particular path of execution because it applies in most cases. But you end up throwing away your work in the case that the prediction turns out to be wrong. In terms of practical application for this - most modern sites run their content over an additional layer of application logic that runs in the browser e.g. React, or Angular or something. These hints can tell the browser that such-and-such an application framework is required to display the content, and to go get it before the content is available.
- chrismorgan 9y agoNo, not idempotent operations; safe operations. When speaking of HTTP methods, PUT and DELETE are both idempotent but not safe; you wouldn’t the user agent to DELETE a resource based on merely a hint—it needs to wait until the actual response comes in, at which point it can confirm whether the header is there and to be acted upon. See https://tools.ietf.org/html/rfc7231#section-4.2 https://tools.ietf.org/html/rfc7231#section-4.2 for the definitions. (Keep in mind with 103’s semantics that we’re not talking about HTTP methods, we’re merely borrowing its definition of “safe”. Speculative JavaScript execution, for example, is perfectly feasible; you’d simply have to pause execution as soon as it tried to mutate its environment or make HTTP requests or things like that. How useful it is is another question.)
- rusk 9y agoI took idempotent and safe to be functionally equivalent. i.e. that which causes no state-change on the server. Thanks for the correction. Effectively a "debounced" operation.
- chrisrhoden 9y agoIdempotent just means that you can do it as many times as you want (n) and the state will remain the same, for n >= 1.
- jkrems 9y agoI'd rather say: It's like the default set if knife/fork/spoon set out at the table. They might be taken away or replaced based on what you actually end up ordering. But for the most part they will work out.