Add caching to a few simple URLs

These do a few queries, and don't change often - ideal for caching
This commit is contained in:
Jake Howard 2022-08-20 18:31:08 +01:00
parent 2a46a70620
commit fd445375ae
Signed by: jake
GPG key ID: 57AFB45680EDD477

View file

@ -1,5 +1,6 @@
from django.conf import settings from django.conf import settings
from django.urls import include, path, re_path from django.urls import include, path, re_path
from django.views.decorators.cache import cache_page
from wagtail import urls as wagtail_urls from wagtail import urls as wagtail_urls
from wagtail.admin import urls as wagtailadmin_urls from wagtail.admin import urls as wagtailadmin_urls
from wagtail.contrib.sitemaps.views import sitemap from wagtail.contrib.sitemaps.views import sitemap
@ -20,9 +21,13 @@ urlpatterns = [
ServeView.as_view(action="redirect"), ServeView.as_view(action="redirect"),
name="wagtailimages_serve", name="wagtailimages_serve",
), ),
path("sitemap.xml", sitemap, name="sitemap"), path("sitemap.xml", cache_page(60 * 60)(sitemap), name="sitemap"),
path("robots.txt", RobotsView.as_view(), name="robotstxt"), path("robots.txt", RobotsView.as_view(), name="robotstxt"),
path(".well-known/security.txt", SecurityView.as_view(), name="securitytxt"), path(
".well-known/security.txt",
cache_page(SecurityView.expires.total_seconds())(SecurityView.as_view()),
name="securitytxt",
),
path("404/", page_not_found, name="404"), path("404/", page_not_found, name="404"),
] ]