Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client-side request caching interceptor #41

Open
rmichela opened this issue Oct 12, 2017 · 0 comments
Open

Client-side request caching interceptor #41

rmichela opened this issue Oct 12, 2017 · 0 comments

Comments

@rmichela
Copy link
Collaborator

Levels of caching

  • Service level - all responses to all operations in this service are cached
  • Operation level - all responses to this operation are cached
  • Response level - this response is cached

The levels are for developer convince. On the wire, all cache control is handled at the response level.

Server side

  • Declararative
    • Services or operations marked with an IdempotencyLevel in their proto will get caching automatically
    • Services or operations can be marked with a protobuf option communicating their desired cache eviction strategy
  • Imperative
    • Service responses programmatically tagged with cache-control metadata during service execution.

On the wire

Cache control policy is communicated to clients using standard HTTP headers on a per-message basis.

  • A gRPC ServerInterceptor converts cache control policy into response HTTP headers.
  • Cacheable service responses are marked with the following HTTP headers
    • Cache-Control:
      • max-age=xxx - the max number of seconds the response can be cached, before requiring a refresh
    • ETag: “ID” - a hash or version of the response used for cache re-validation

Client Side

  • Client-side caching handled by a client interceptor
  • The client specifies the maximum size of the cache in megabytes using some kind of configuration
  • If a cache line is expired but not yet evicted, the next request for the cached request will include an If-None-Match: xxx header, including the etag of the expired cached response
  • If the server's response has still not changed after cache expiration, a HTTP 304 Not Modified response with a fresh Cache-Control header will be sent in lieu of the response message, instructing the client to continue relying on its cache.
rmichela pushed a commit that referenced this issue Dec 18, 2022
build(deps): bump spring.version from 6.0.0 to 6.0.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant