code: public static void addCacheControlAndEtagToResult(Result result, String etag, ApplicationConfiguration configuration) {
          String maxAge = configuration.getWithDefault(HTTP_CACHE_CONTROL_MAX_AGE,
                  HTTP_CACHE_CONTROL_DEFAULT);
  
          if ("0".equals(maxAge)) {
              result.with(HeaderNames.CACHE_CONTROL, "no-cache");
          } else {
              result.with(HeaderNames.CACHE_CONTROL, "max-age=" + maxAge);
          }
  
          // Use etag on demand:
          boolean useEtag = configuration.getBooleanWithDefault(HTTP_USE_ETAG,
                  HTTP_USE_ETAG_DEFAULT);
  
          if (useEtag) {
              result.with(HeaderNames.ETAG, etag);
          }
      }
docs: Adds cache control and etag to the given result.
  
  @param result        the result
  @param etag          the etag
  @param configuration the application configuration