From 5f85b2717cbc454fd09b143ef6887856b3d98322 Mon Sep 17 00:00:00 2001 From: Tuneer Roy <53184517+tuneerroy@users.noreply.github.com> Date: Fri, 15 Sep 2023 12:07:59 -0400 Subject: [PATCH] feat: caching of some dining routes --- backend/dining/urls.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/backend/dining/urls.py b/backend/dining/urls.py index 35415d2a..a80e589f 100644 --- a/backend/dining/urls.py +++ b/backend/dining/urls.py @@ -1,5 +1,6 @@ from django.urls import path from django.views.decorators.cache import cache_page +from backend.utils.cache import HOUR_IN_SECONDS, MONTH_IN_SECONDS_APPROX from dining.views import Menus, Preferences, Venues @@ -7,10 +8,22 @@ urlpatterns = [ path( "venues/", - cache_page(30 * 24 * 60 * 60)(Venues), + cache_page(1 * MONTH_IN_SECONDS_APPROX)(Venues), name="venues", ), - path("menus/", Menus.as_view(), name="menus"), - path("menus//", Menus.as_view(), name="menus-with-date"), - path("preferences/", Preferences.as_view(), name="dining-preferences"), + path( + "menus/", + cache_page(1 * HOUR_IN_SECONDS)(Menus), + name="menus", + ), + path( + "menus//", + cache_page(1 * HOUR_IN_SECONDS)(Menus), + name="menus-with-date", + ), + path( + "preferences/", + Preferences.as_view(), + name="dining-preferences", + ), ]