From a8ea9844dcb79066273bfc2f550e4e5e642034ad Mon Sep 17 00:00:00 2001 From: Feanil Patel Date: Thu, 12 Dec 2019 11:40:59 -0500 Subject: [PATCH] Deal with cache misses. --- common/djangoapps/util/cache.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/common/djangoapps/util/cache.py b/common/djangoapps/util/cache.py index bc9503aaff..1305ed63a7 100644 --- a/common/djangoapps/util/cache.py +++ b/common/djangoapps/util/cache.py @@ -77,13 +77,13 @@ def cache_if_anonymous(*get_parameters): response = cache.get(cache_key) # pylint: disable=maybe-no-member - # A hack to ensure that the response data is a valid text type for both Python 2 and 3. - response_content = response._container.copy() # pylint: disable=protected-member - response.content = b'' - for item in response_content: - response.write(item) - - if not response: + if response: + # A hack to ensure that the response data is a valid text type for both Python 2 and 3. + response_content = response._container.copy() # pylint: disable=protected-member + response.content = b'' + for item in response_content: + response.write(item) + else: response = view_func(request, *args, **kwargs) cache.set(cache_key, response, 60 * 3) # pylint: disable=maybe-no-member