v.25.11Improvement

HTTP interface will provide Age and Expires

The HTTP interface will provide Age and Expires headers when the query result cache is used. The presence of the Age header tells whether the result is from the cache, while Expires is also set at the first write. Introduce new profile events: QueryCacheAgeSeconds, QueryCacheReadRows, QueryCacheReadBytes, QueryCacheWrittenRows, QueryCacheWrittenBytes. #89759 (Alexey Milovidov).
The HTTP interface in ClickHouse now includes Age and Expires headers when serving query results from the cache, along with new profile events related to query result caching.

Why it matters

This feature enables users to identify when query results are served from the cache by checking the Age header and understand cache expiration via the Expires header. Additionally, the new profile events provide detailed metrics about cache usage, such as the age of cached results and the number of rows and bytes read from or written to the cache. This improves observability and helps optimize query performance by leveraging cached results more effectively.

How to use it

When using the HTTP interface, monitor the Age and Expires headers in the HTTP response to determine cache usage and validity. Use the new profile events QueryCacheAgeSeconds, QueryCacheReadRows, QueryCacheReadBytes, QueryCacheWrittenRows, and QueryCacheWrittenBytes in query profiling to analyze cache behavior and performance.