Skip to content
Playground(another site)

bynk.http.cache_on_non_get

Error A @cache annotation is placed on a handler that is not on http GET.

@cache declares how long the response to a read may be reused, so it is legal only on an on GET handler. Conditional caching applies to safe, idempotent reads, and a POST, PUT, PATCH or DELETE is neither. Remove the annotation, or, if the route only reads, make it a GET. A GET is revalidated by its ETag with no annotation at all.

Example

@cache(maxAge: 5.minutes) // ✗ a `POST` changes something
on POST("/refresh") () -> Effect[HttpResult[String]] by v: Visitor { … }
@cache(maxAge: 5.minutes) // ✓ a read
on GET("/links") () -> Effect[HttpResult[String]] by v: Visitor { … }

In the Book

See also

  • Every code in its category, HTTP, on the diagnostic index.
  • bynk explain bynk.http.cache_on_non_get shows the same from the installed toolchain, without a network.