diff --git a/django/utils/cache.py b/django/utils/cache.py
index 6cfd893..5894c76 100644
a
|
b
|
def patch_response_headers(response, cache_timeout=None):
|
101 | 101 | cache_timeout = settings.CACHE_MIDDLEWARE_SECONDS |
102 | 102 | if cache_timeout < 0: |
103 | 103 | cache_timeout = 0 # Can't have max-age negative |
104 | | if not response.has_header('ETag'): |
| 104 | if settings.USE_ETAGS and not response.has_header('ETag'): |
105 | 105 | response['ETag'] = '"%s"' % md5_constructor(response.content).hexdigest() |
106 | 106 | if not response.has_header('Last-Modified'): |
107 | 107 | response['Last-Modified'] = http_date() |
diff --git a/docs/ref/settings.txt b/docs/ref/settings.txt
index b5556de..4d70440 100644
a
|
b
|
USE_ETAGS
|
1640 | 1640 | Default: ``False`` |
1641 | 1641 | |
1642 | 1642 | A boolean that specifies whether to output the "Etag" header. This saves |
1643 | | bandwidth but slows down performance. This is only used if ``CommonMiddleware`` |
1644 | | is installed (see :doc:`/topics/http/middleware`). |
| 1643 | bandwidth but slows down performance. This is only in the ``CommonMiddleware`` (see :doc:`/topics/http/middleware`) and in the ``Cache Framework`` (see :doc:`/topics/cache`). |
1645 | 1644 | |
1646 | 1645 | .. setting:: USE_I18N |
1647 | 1646 | |
diff --git a/tests/regressiontests/cache/tests.py b/tests/regressiontests/cache/tests.py
index 1e0a404..acc8837 100644
a
|
b
|
class CacheI18nTest(unittest.TestCase):
|
628 | 628 | settings.CACHE_MIDDLEWARE_SECONDS = 60 |
629 | 629 | settings.CACHE_MIDDLEWARE_KEY_PREFIX="test" |
630 | 630 | settings.CACHE_BACKEND='locmem:///' |
| 631 | settings.USE_ETAGS = True |
631 | 632 | settings.USE_I18N = True |
632 | 633 | en_message ="Hello world!" |
633 | 634 | es_message ="Hola mundo!" |
… |
… |
class CacheI18nTest(unittest.TestCase):
|
638 | 639 | # Check that we can recover the cache |
639 | 640 | self.assertNotEqual(get_cache_data.content, None) |
640 | 641 | self.assertEqual(en_message, get_cache_data.content) |
| 642 | # Check that we use etags |
| 643 | self.assertTrue(get_cache_data.has_header('ETag')) |
| 644 | # Check that we can disable etags |
| 645 | settings.USE_ETAGS = False |
| 646 | request._cache_update_cache = True |
| 647 | set_cache(request, 'en', en_message) |
| 648 | get_cache_data = FetchFromCacheMiddleware().process_request(request) |
| 649 | self.assertFalse(get_cache_data.has_header('ETag')) |
641 | 650 | # change the session language and set content |
642 | 651 | request = self._get_request_cache() |
643 | 652 | set_cache(request, 'es', es_message) |