Class AgentCardCacheMetadata

java.lang.Object
org.a2aproject.sdk.server.AgentCardCacheMetadata

@ApplicationScoped public class AgentCardCacheMetadata extends Object
Provides HTTP caching metadata for Agent Card responses.

This bean computes and caches HTTP caching headers (Cache-Control, ETag, Last-Modified) for the Agent Card endpoint as specified in the A2A protocol specification section 8.6.

The metadata is computed once at initialization:

  • Cache-Control: Configured via a2a.agent-card.cache.max-age (default: 3600 seconds)
  • ETag: MD5 hash of the serialized Agent Card JSON
  • Last-Modified: Timestamp when the bean was initialized (RFC 1123 format)

Since the Agent Card is @ApplicationScoped, these values remain stable throughout the application lifecycle unless the application is restarted.

See Also:
  • Constructor Details

    • AgentCardCacheMetadata

      public AgentCardCacheMetadata(AgentCard agentCard, A2AConfigProvider config)
      Public constructor for testing purposes.
      Parameters:
      agentCard - the agent card
      config - the configuration provider
  • Method Details

    • getETag

      public String getETag()
      Returns the ETag header value for the Agent Card.

      The ETag is an MD5 hash of the serialized Agent Card JSON, quoted per HTTP specification.

      Returns:
      the ETag header value (e.g., "a1b2c3d4...")
    • getLastModified

      public String getLastModified()
      Returns the Last-Modified header value for the Agent Card.

      The timestamp represents when the bean was initialized, in RFC 1123 format.

      Returns:
      the Last-Modified header value (e.g., "Mon, 17 Mar 2025 10:00:00 GMT")
    • getCacheControl

      public String getCacheControl()
      Returns the Cache-Control header value for the Agent Card.

      The value includes public and a max-age directive configured via a2a.agent-card.cache.max-age (default: 3600 seconds).

      Returns:
      the Cache-Control header value (e.g., "public, max-age=3600")
    • getHttpHeadersMap

      public Map<String,String> getHttpHeadersMap()
      Populates a map with header names and header values stored in this instance.
      Returns:
      a map of the headers