AggregatedHttpMessage maybeCacheNames(boolean shouldCacheControl, List<String> values) {
    Collections.sort(values);
    byte[] body = JsonCodec.writeList(QUOTED_STRING_WRITER, values);
    HttpHeaders headers = HttpHeaders.of(200)
      .contentType(MediaType.JSON)
      .setInt(HttpHeaderNames.CONTENT_LENGTH, body.length);
    if (shouldCacheControl) {
      headers = headers.add(
        HttpHeaderNames.CACHE_CONTROL,
        CacheControl.maxAge(namesMaxAge, TimeUnit.SECONDS).mustRevalidate().getHeaderValue()
      );
    }
    return AggregatedHttpMessage.of(headers, HttpData.of(body));
  }
AggregatedHttpMessage maybeCacheNames ( boolean shouldCacheControl , List < String > values ) { Collections . sort ( values ) ; byte [ ] body = JsonCodec . writeList ( QUOTED_STRING_WRITER , values ) ; HttpHeaders headers = HttpHeaders . of ( 200 ) . contentType ( MediaType . JSON ) . setInt ( HttpHeaderNames . CONTENT_LENGTH , body . length ) ; if ( shouldCacheControl ) { headers = headers . add ( HttpHeaderNames . CACHE_CONTROL , CacheControl . maxAge ( namesMaxAge , TimeUnit . SECONDS ) . mustRevalidate ( ) . getHeaderValue ( ) ) ; } return AggregatedHttpMessage . of ( headers , HttpData . of ( body ) ) ; }
We cache names if there are more than 3 names. This helps people getting started: if we cache
empty results, users have more questions. We assume caching becomes a concern when zipkin is in
active use, and active use usually implies more than 3 services.