Skip to content

Commit

Permalink
Added caching on /api/schema/ endpoint (closes #15894)
Browse files Browse the repository at this point in the history
  • Loading branch information
mulmat authored and jeremystretch committed May 1, 2024
1 parent 365bb4b commit d256c04
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion netbox/netbox/urls.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django.conf import settings
from django.conf.urls import include
from django.urls import path
from django.views.decorators.cache import cache_page
from django.views.decorators.csrf import csrf_exempt
from django.views.static import serve
from drf_spectacular.views import SpectacularAPIView, SpectacularRedocView, SpectacularSwaggerView
Expand Down Expand Up @@ -56,7 +57,13 @@
path('api/wireless/', include('wireless.api.urls')),
path('api/status/', StatusView.as_view(), name='api-status'),

path('api/schema/', SpectacularAPIView.as_view(), name='schema'),
path(
"api/schema/",
cache_page(timeout=86400, key_prefix=f"api_schema_{settings.VERSION}")(
SpectacularAPIView.as_view()
),
name="schema",
),
path('api/schema/swagger-ui/', SpectacularSwaggerView.as_view(url_name='schema'), name='api_docs'),
path('api/schema/redoc/', SpectacularRedocView.as_view(url_name='schema'), name='api_redocs'),

Expand Down

0 comments on commit d256c04

Please sign in to comment.