Get Requests and Caching
Connect supports performing idempotent, side-effect free requests using an HTTP GET-based protocol. This makes it easier to cache certain kinds of requests in the browser, on your CDN, or in proxies and other middleboxes.
First, configure your server to handle HTTP GET requests using Connect. Refer to the documentation that corresponds to your server:
If you are using clients to make query-style requests, you may want the ability
to use Connect HTTP GET request support. To opt-in for a given procedure, you
must mark it as being side-effect free using the
MethodOptions.IdempotencyLevel
option:
service ElizaService {
rpc Say(stream SayRequest) returns (SayResponse) {
option idempotency_level = NO_SIDE_EFFECTS;
}
}
Clients will not automatically use GET requests by default.
To do that, you'll need to update your ProtocolClientConfig
with
the enabled GETConfiguration
.
val config = ProtocolClientConfig(
getConfiguration = GETConfiguration.Enabled,
...
)