News for hackers. Stuff that matters.
Re:Defining a new HTTP method: HTTP Search (2021) by zeroimpl on Saturday May 27, 2023 @01:13PM (#36096385)
TIL sending a POST request to a URL invalidates the cache for GET requests of the same URL.

Going to have to review my REST APIs to make sure that’s not a problem.

Re:Defining a new HTTP method: HTTP Search (2021) by tacone on Saturday May 27, 2023 @02:11PM (#36096865)
Incredible, I did not know that. Does anybody point out to some resources to learn more about this behavior?
Re:Defining a new HTTP method: HTTP Search (2021) by brabel on Saturday May 27, 2023 @02:37PM (#36097089)
I'm sorry, but isn't that the most basic thing possible about GET and POST?? GET is used to read a resource, POST to write to it... why would you NOT expect writing to a resource to invalidate caches of that resource??
Re:Defining a new HTTP method: HTTP Search (2021) by tacone on Saturday May 27, 2023 @03:20PM (#36097399)
Because usually GET /posts gets you a list of posts, POST /posts create a new one.
Re:Defining a new HTTP method: HTTP Search (2021) by JulianWasTaken on Saturday May 27, 2023 @03:30PM (#36097469)
I don't know what level of incredulity is appropriate in my opinion (probably not as much as the parent comment), but isn't that another good reason to expect cache invalidation? Surely creating new posts would expectedly invalidate the list of posts cached, it has to now include at least one new one.
Re:Defining a new HTTP method: HTTP Search (2021) by zeroimpl on Saturday May 27, 2023 @04:00PM (#36097709)
I think you’d have to have a fairly awkward API design in order for this to be an issue. For example, if “POST /posts” does something else, like flags a post for a moderator to review.

That being said, I don’t see this feature being particularly beneficial either. Only the caches which observed the request could know to purge the cache. So you can’t actually rely on it for cache invalidation.