|
|
|
|
|
by gls2ro
1433 days ago
|
|
404 is consistent with the way a HTTP server works if what you build is not a dynamic app but a static website. If you try to request a file `/public/pdfs/100.pdf` and that does not exists what does the server respond? 404 What the server responds if you try `/public/dpdfs/1.pdf`? Still 404 as that path does not exists on the local storage. What is the difference for a client if 100.pdf should be an actually file or a data stream served from a web framework? There should be no difference. Choosing to behave when building a dynamic app the same way as the static helps a lot with integrating with multiple other services (eg. caching, observability ...) |
|
>The 200 (OK) status code indicates that the request has succeeded. The payload sent in a 200 response depends on the request method. For the methods defined by this specification, the intended meaning of the payload can be summarized as:
>GET a representation of the target resource;
>The 404 (Not Found) status code indicates that the origin server did not find a current representation for the target resource or is not willing to disclose that one exists.
If you to give the client the representation of the target resource (i.e. it doesn't exist) then send 200 and a body indicating it doesn't exist.
If you want to tell the client you couldn't find a representation for the target resource then send 404