'Calculate the ETag, if needed.'

def process_response(self, request, response):

    if settings.SEND_BROKEN_LINK_EMAILS:
        warnings.warn('SEND_BROKEN_LINK_EMAILS    is    deprecated.    Use    BrokenLinkEmailsMiddleware    instead.', PendingDeprecationWarning, stacklevel=2)
        BrokenLinkEmailsMiddleware().process_response(request, response)
    if settings.USE_ETAGS:
        if response.has_header('ETag'):
            etag = response['ETag']
        elif response.streaming:
            etag = None
        else:
            etag = ('"%s"' % hashlib.md5(response.content).hexdigest())
        if (etag is not None):
            if ((200 <= response.status_code < 300) and (request.META.get('HTTP_IF_NONE_MATCH') == etag)):
                cookies = response.cookies
                response = http.HttpResponseNotModified()
                response.cookies = cookies
            else:
                response['ETag'] = etag
    return response
