From b8460b0acd3e833b9ec302d9fa3fb6ab28032c0e Mon Sep 17 00:00:00 2001 From: Michael Manfre Date: Tue, 6 Dec 2022 00:23:07 -0500 Subject: Only cache unauthenticated page views (#117) --- activities/views/follows.py | 4 ---- activities/views/posts.py | 6 ++++-- activities/views/timelines.py | 10 +++------- 3 files changed, 7 insertions(+), 13 deletions(-) (limited to 'activities') diff --git a/activities/views/follows.py b/activities/views/follows.py index 841c8cc..44d8adc 100644 --- a/activities/views/follows.py +++ b/activities/views/follows.py @@ -1,15 +1,11 @@ from django.utils.decorators import method_decorator from django.views.generic import TemplateView -from core.decorators import per_identity_cache_page from users.decorators import identity_required from users.models import FollowStates @method_decorator(identity_required, name="dispatch") -@method_decorator( - per_identity_cache_page("cache_timeout_page_timeline"), name="dispatch" -) class FollowsPage(TemplateView): """ Shows followers/follows. diff --git a/activities/views/posts.py b/activities/views/posts.py index adc732c..d343567 100644 --- a/activities/views/posts.py +++ b/activities/views/posts.py @@ -6,13 +6,15 @@ from django.utils.decorators import method_decorator from django.views.generic import TemplateView, View from activities.models import Post, PostInteraction, PostInteractionStates, PostStates -from core.decorators import per_identity_cache_page +from core.decorators import cache_page_by_ap_json from core.ld import canonicalise from users.decorators import identity_required from users.shortcuts import by_handle_or_404 -@method_decorator(per_identity_cache_page("cache_timeout_page_post"), name="dispatch") +@method_decorator( + cache_page_by_ap_json("cache_timeout_page_post", public_only=True), name="dispatch" +) class Individual(TemplateView): template_name = "activities/post.html" diff --git a/activities/views/timelines.py b/activities/views/timelines.py index 2b456ad..711c357 100644 --- a/activities/views/timelines.py +++ b/activities/views/timelines.py @@ -5,13 +5,12 @@ from django.utils.decorators import method_decorator from django.views.generic import FormView, ListView from activities.models import Hashtag, Post, PostInteraction, TimelineEvent -from core.decorators import per_identity_cache_page +from core.decorators import cache_page from core.models import Config from users.decorators import identity_required @method_decorator(identity_required, name="dispatch") -@method_decorator(per_identity_cache_page(), name="dispatch") class Home(FormView): template_name = "activities/home.html" @@ -64,7 +63,7 @@ class Home(FormView): @method_decorator( - per_identity_cache_page("cache_timeout_page_timeline"), name="dispatch" + cache_page("cache_timeout_page_timeline", public_only=True), name="dispatch" ) class Tag(ListView): @@ -102,7 +101,7 @@ class Tag(ListView): @method_decorator( - per_identity_cache_page("cache_timeout_page_timeline"), name="dispatch" + cache_page("cache_timeout_page_timeline", public_only=True), name="dispatch" ) class Local(ListView): @@ -130,9 +129,6 @@ class Local(ListView): @method_decorator(identity_required, name="dispatch") -@method_decorator( - per_identity_cache_page("cache_timeout_page_timeline"), name="dispatch" -) class Federated(ListView): template_name = "activities/federated.html" -- cgit v1.2.3