Skip to content

Commit

Permalink
feat: add http cache
Browse files Browse the repository at this point in the history
  • Loading branch information
loadez committed Sep 6, 2024
1 parent 320bb8b commit 36ecbab
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 9 deletions.
9 changes: 9 additions & 0 deletions backend/kernelCI/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,13 @@ def get_json_env_var(name, default):
}


CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
'LOCATION': 'ecom',
}
}

# Password validation
# https://docs.djangoproject.com/en/5.0/ref/settings/#auth-password-validators

Expand Down Expand Up @@ -188,3 +195,5 @@ def __getitem__(self, item):
CSRF_COOKIE_SECURE = False
SECURE_SSL_REDIRECT = False
SECURE_HSTS_SECONDS = 3600

CACHE_TIMEOUT = int(get_json_env_var("CACHE_TIMEOUT", "600"))
29 changes: 20 additions & 9 deletions backend/kernelCI_app/urls.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,29 @@
from django.urls import path
from django.views.decorators.cache import cache_page
from django.conf import settings
from kernelCI_app import views

timeout = settings.CACHE_TIMEOUT

urlpatterns = [
path("tree/", views.TreeView.as_view(), name="tree"),
path("tree/<str:commit_hash>/commits", views.TreeCommitsHistory.as_view(), name="treeCommits"),
path("tree/tests/", views.groupedTests.as_view(), name="treeGroupedTests"),
path("tree/<str:commit_hash>", views.TreeDetails.as_view(), name="treeDetails"),
path("tree/", cache_page(timeout)
(views.TreeView.as_view()), name="tree"),
path("tree/<str:commit_hash>/commits", cache_page(timeout)
(views.TreeCommitsHistory.as_view()), name="treeCommits"),
path("tree/tests/", cache_page(timeout)
(views.groupedTests.as_view()), name="treeGroupedTests"),
path("tree/<str:commit_hash>", cache_page(timeout)
(views.TreeDetails.as_view()), name="treeDetails"),
path(
"tree/<str:commit_hash>/tests/", views.TreeTestsView.as_view(), name="treeTests"
"tree/<str:commit_hash>/tests/",
cache_page(timeout)(views.TreeTestsView.as_view()), name="treeTests"
),
path("build/<str:build_id>", views.BuildDetails.as_view(), name="buildDetails"),
path("build/<str:build_id>/tests", views.BuildTests.as_view(), name="buildTests"),
path("tests/test/<str:test_id>", views.TestDetails.as_view(), name="testDetails"),
path("build/<str:build_id>", cache_page(timeout)
(views.BuildDetails.as_view()), name="buildDetails"),
path("build/<str:build_id>/tests", cache_page(timeout)
(views.BuildTests.as_view()), name="buildTests"),
path("tests/test/<str:test_id>", cache_page(timeout)
(views.TestDetails.as_view()), name="testDetails"),
path("tests/<str:commit_hash>",
views.TestsByTreeAndCommitHash.as_view(), name="testsByTreeAndCommitHash"),
cache_page(timeout)(views.TestsByTreeAndCommitHash.as_view()), name="testsByTreeAndCommitHash"),
]

0 comments on commit 36ecbab

Please sign in to comment.