1

How to enforce http header no-cache when generating following protobuf?

Suppose we have the following rpc method defined within a proto file, including the http option. the http get option enables us to also generated a http gateway API endpoint

// AssignTask gets a specific task type and id for the current logged in user     
rpc AssignTask (google.protobuf.Empty) returns (AssignTaskResponse) {
   option (google.api.http) = {
      get: "/v1/task/assign"
   };
}

When generating the api with ProtoC

The problem we faced is that some browsers might cache this particular api call because caching enabled in the browser. Even if the payload of the request would contain the user the GET call could be cached by the browser if the response does not have the http no-cache header.

The question is how can we enforce the http no-cache in the response of the generated api via a definition in the proto file?

Hace
  • 1,421
  • 12
  • 17
  • Could it be this feature: https://github.com/grpc/grpc/issues/7945 – Hace Jan 09 '18 at 15:47
  • you may be able to send cache control response headers in your implementation code instead of trying to define them in the proto file. here is a question on how to do that in golang: https://stackoverflow.com/questions/48631477/how-to-define-response-headers-for-unary-rpc – thurt Feb 05 '18 at 23:03

0 Answers0