From 1832976b94c8a1a243907e13ed8122ba8917c505 Mon Sep 17 00:00:00 2001
From: Henrik Levkowetz <henrik@levkowetz.com>
Date: Thu, 22 Oct 2020 11:25:24 +0000
Subject: [PATCH] Added caching for the /doc/active page.  - Legacy-Id: 18625

---
 ietf/doc/views_search.py                    | 7 +++++--
 ietf/templates/doc/index_active_drafts.html | 4 +++-
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/ietf/doc/views_search.py b/ietf/doc/views_search.py
index 3bf12a4d9..9406912f7 100644
--- a/ietf/doc/views_search.py
+++ b/ietf/doc/views_search.py
@@ -544,8 +544,11 @@ def index_all_drafts(request):
     return render(request, 'doc/index_all_drafts.html', { "categories": categories })
 
 def index_active_drafts(request):
-    groups = active_drafts_index_by_group()
-
+    cache_key = 'doc:index_active_drafts'
+    groups = cache.get(cache_key)
+    if not groups:
+        groups = active_drafts_index_by_group()
+        cache.set(cache_key, groups, 15*60)
     return render(request, "doc/index_active_drafts.html", { 'groups': groups })
 
 def ajax_select2_search_docs(request, model_name, doc_type):
diff --git a/ietf/templates/doc/index_active_drafts.html b/ietf/templates/doc/index_active_drafts.html
index e9a02f885..924b95174 100644
--- a/ietf/templates/doc/index_active_drafts.html
+++ b/ietf/templates/doc/index_active_drafts.html
@@ -2,9 +2,11 @@
 {# Copyright The IETF Trust 2015, All Rights Reserved #}
 {% load origin %}
 {% load static %}
+{% load cache %}
 {% block title %}Active Internet-Drafts{% endblock %}
 
 {% block content %}
+  {% cache 900 ietf_doc_index_active_drafts %}
   {% origin %}
   <h1>Active Internet-Drafts</h1>
 
@@ -35,5 +37,5 @@
       </p>
     {% endfor %}
   {% endfor %}
-
+  {% endcache %}
 {% endblock %}