SimpleHttpResponse generateNotModifiedResponse(final HttpCacheEntry entry) {

        final SimpleHttpResponse response = new SimpleHttpResponse(HttpStatus.SC_NOT_MODIFIED, "Not Modified");

        // The response MUST include the following headers

        // - Date
        Header dateHeader = entry.getFirstHeader(HttpHeaders.DATE);
        if (dateHeader == null) {
            dateHeader = new BasicHeader(HttpHeaders.DATE, DateUtils.formatStandardDate(Instant.now()));
        }
        response.addHeader(dateHeader);

        // - ETag and/or Content-Location, if the header would have been sent
        //   in a 200 response to the same request
        final ETag eTag = entry.getETag();
        if (eTag != null) {
            response.addHeader(new BasicHeader(HttpHeaders.ETAG, eTag.toString()));
        }

        final Header contentLocationHeader = entry.getFirstHeader(HttpHeaders.CONTENT_LOCATION);
        if (contentLocationHeader != null) {
            response.addHeader(contentLocationHeader);
        }

        // - Expires, Cache-Control, and/or Vary, if the field-value might
        //   differ from that sent in any previous response for the same
        //   variant
        final Header expiresHeader = entry.getFirstHeader(HttpHeaders.EXPIRES);
        if (expiresHeader != null) {
            response.addHeader(expiresHeader);
        }

        final Header cacheControlHeader = entry.getFirstHeader(HttpHeaders.CACHE_CONTROL);
        if (cacheControlHeader != null) {
            response.addHeader(cacheControlHeader);
        }

        final Header varyHeader = entry.getFirstHeader(HttpHeaders.VARY);
        if (varyHeader != null) {
            response.addHeader(varyHeader);
        }

        //Since the goal of a 304 response is to minimize information transfer
        //when the recipient already has one or more cached representations, a
        //sender SHOULD NOT generate representation metadata other than the
        //above listed fields unless said metadata exists for the purpose of
        //guiding cache updates (e.g., Last-Modified might be useful if the
        //response does not have an ETag field).
        if (eTag == null) {
            final Header lastModifiedHeader = entry.getFirstHeader(HttpHeaders.LAST_MODIFIED);
            if (lastModifiedHeader != null) {
                response.addHeader(lastModifiedHeader);
            }
        }
        return response;
    }
Generate a 304 - Not Modified response from the {@link HttpCacheEntry}. This should be
used to respond to conditional requests, when the entry exists or has been re-validated.
httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/CachedHttpResponseGenerator.java