diff --git a/codethesaurus/settings.py b/codethesaurus/settings.py index ab498e543..8a7bd67c1 100644 --- a/codethesaurus/settings.py +++ b/codethesaurus/settings.py @@ -51,11 +51,13 @@ MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', + 'django.middleware.cache.UpdateCacheMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', - 'django.middleware.clickjacking.XFrameOptionsMiddleware' + 'django.middleware.clickjacking.XFrameOptionsMiddleware', + 'django.middleware.cache.FetchFromCacheMiddleware' ] ROOT_URLCONF = 'codethesaurus.urls' @@ -147,5 +149,20 @@ os.path.join(BASE_DIR, 'static'), ] +if os.getenv('DJANGO_DEVELOPMENT') == 'true': + CACHES = { + 'default': { + 'BACKEND': 'django.core.cache.backends.dummy.DummyCache', + } + } +else: + CACHES = { + 'default': { + 'BACKEND': 'django.core.cache.backends.db.DatabaseCache', + 'LOCATION': 'cache_table', + 'TIMEOUT': 3600 + } + } + # Configure Django App for Heroku. django_on_heroku.settings(locals(), test_runner=False, databases=False, staticfiles=True, logging=True)