From 67db0a801322d28542a872028a311e0980373e8f Mon Sep 17 00:00:00 2001 From: Christophe Siraut Date: Thu, 15 Nov 2018 15:00:54 +0100 Subject: [PATCH] health api: cache results (#26836) --- debian/debian_config_common.py | 2 ++ hobo/rest/urls.py | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/debian/debian_config_common.py b/debian/debian_config_common.py index 685898f..b8a5360 100644 --- a/debian/debian_config_common.py +++ b/debian/debian_config_common.py @@ -369,3 +369,5 @@ HOBO_ANONYMOUS_SERVICE_USER_CLASS = 'hobo.rest_authentication.AnonymousAdminServ THEMES_DIRECTORY = '/usr/share/publik/themes/' USE_X_FORWARDED_FOR = True + +HEALTHAPI_TIMEOUT = 600 diff --git a/hobo/rest/urls.py b/hobo/rest/urls.py index 75675b7..34a9530 100644 --- a/hobo/rest/urls.py +++ b/hobo/rest/urls.py @@ -14,9 +14,17 @@ # You should have received a copy of the GNU General Public License # along with this program; if not, see . +from django.conf import settings from django.conf.urls import url +from django.views.decorators.cache import cache_page from .views import HealthList +try: + timeout = settings.HEALTHAPI_TIMEOUT +except AttributeError: + timeout = 600 + + urlpatterns = [ - url(r'^health/$', HealthList.as_view(), name='api-health-list'), + url(r'^health/$', cache_page(timeout)(HealthList.as_view()), name='api-health-list'), ] -- 2.19.1