Skip to content
Playground(another site)

bynk.http.cache_bad_max_age

Error A @cache annotation's maxAge is missing or not a positive Duration literal.

@cache says how long a client or cache may reuse a GET response without asking again, so it needs a maxAge, and that must be a positive Duration literal. A bare number or a string is refused; write a Duration literal whose unit agrees with its number: 30.seconds, 5.minutes, 1.hour. A positive duration that is not a whole number of seconds is bynk.http.cache_max_age_fractional_seconds.

Example

@cache(maxAge: 3600) // ✗ a bare number, not a `Duration`
on GET("/links") () -> Effect[HttpResult[String]] by v: Visitor { … }
@cache(maxAge: 1.hour) // ✓
on GET("/links") () -> Effect[HttpResult[String]] by v: Visitor { … }
const Fresh: Duration = 1.hour
@cache(maxAge: Fresh) // ✓ a `Duration` constant bound to a literal
on GET("/docs") () -> 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_bad_max_age shows the same from the installed toolchain, without a network.