0

I am developing RESTful Api micro service which is cache all data in memory (and update it every n minutes from persistent storage). Service has an api for immediate cache updating /update-cache.

What is best http verb for updating cache?

GET, POST, PUT, PATCH or i need to create some custom verb

Dmitriy O.
  • 63
  • 6
  • If you don't want neither to send any kind of "body" nor explicitly update any resource you should use GET – Irek L. Dec 18 '18 at 12:54
  • 1
    This is what I thought. But specification required `GET` to be safe: > An HTTP method is safe if it doesn't alter the state of the server. In other words, a method is safe if it leads to a read-only operation. © https://developer.mozilla.org/en-US/docs/Glossary/safe Which seems not quite true to me for cache update operation – Dmitriy O. Dec 18 '18 at 14:31
  • 1
    If you want to follow "specifications" you should not use REST to call the service/function. REST is by definition for operating on resources (and "update-..." is not a resource - it is a verb). You can try something like `DELETE /cache` but for me it looks a bit "exotic" – Irek L. Dec 18 '18 at 15:15

1 Answers1

1

What your proposing is not really RESTful, it's more like an RPC-style operation. For this POST is fine.

Evert
  • 93,428
  • 18
  • 118
  • 189