From cc29011033adcb3b482fdfc639a62eda16d83adb Mon Sep 17 00:00:00 2001 From: Jason Date: Tue, 6 Feb 2024 21:33:47 -0500 Subject: [PATCH] cache schema Signed-off-by: Jason --- metropolis/urls.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/metropolis/urls.py b/metropolis/urls.py index 699c4b33..f0f83e30 100644 --- a/metropolis/urls.py +++ b/metropolis/urls.py @@ -19,6 +19,7 @@ from django.contrib import admin from django.http import FileResponse from django.urls import include, path, re_path +from django.views.decorators.cache import cache_page from drf_spectacular.views import ( SpectacularSwaggerView, SpectacularAPIView, @@ -52,7 +53,9 @@ def service_worker(request): path("select2/", include("django_select2.urls")), path("", include("django.contrib.flatpages.urls")), path("docs", SpectacularSwaggerView.as_view(url_name="schema"), name="swagger-ui"), - path("api/schema/", SpectacularAPIView.as_view(), name="schema"), + path( + "api/schema/", cache_page(60 * 30)(SpectacularAPIView.as_view()), name="schema" + ), # cache for 30m path("docs/redoc/", SpectacularRedocView.as_view(url_name="schema"), name="redoc"), ]