From 86ad247c50b490b4b5abde506882b9b219916aed Mon Sep 17 00:00:00 2001 From: Oliver Date: Thu, 23 Mar 2023 13:32:38 +1100 Subject: [PATCH] Reduce cache timeout for reports and labels --- InvenTree/label/api.py | 6 +++--- InvenTree/report/api.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/InvenTree/label/api.py b/InvenTree/label/api.py index f07a8f891c..80ee4c926e 100644 --- a/InvenTree/label/api.py +++ b/InvenTree/label/api.py @@ -5,7 +5,7 @@ from django.core.exceptions import FieldError, ValidationError from django.http import HttpResponse, JsonResponse from django.urls import include, re_path from django.utils.decorators import method_decorator -from django.views.decorators.cache import cache_page, never_cache +from django.views.decorators.cache import cache_page from django_filters.rest_framework import DjangoFilterBackend from rest_framework import filters @@ -136,11 +136,11 @@ class LabelListView(LabelFilterMixin, ListAPI): ] -@method_decorator(cache_page(5), name='dispatch') +@method_decorator(cache_page(2), name='dispatch') class LabelPrintMixin(LabelFilterMixin): """Mixin for printing labels.""" - @method_decorator(never_cache) + @method_decorator(cache_page(1)) def dispatch(self, *args, **kwargs): """Prevent caching when printing report templates""" return super().dispatch(*args, **kwargs) diff --git a/InvenTree/report/api.py b/InvenTree/report/api.py index 8fb7182e3a..8a81f7e1e6 100644 --- a/InvenTree/report/api.py +++ b/InvenTree/report/api.py @@ -7,7 +7,7 @@ from django.template.exceptions import TemplateDoesNotExist from django.urls import include, path, re_path from django.utils.decorators import method_decorator from django.utils.translation import gettext_lazy as _ -from django.views.decorators.cache import cache_page, never_cache +from django.views.decorators.cache import cache_page from django_filters.rest_framework import DjangoFilterBackend from rest_framework import filters @@ -140,11 +140,11 @@ class ReportFilterMixin: return queryset -@method_decorator(cache_page(5), name='dispatch') +@method_decorator(cache_page(1), name='dispatch') class ReportPrintMixin: """Mixin for printing reports.""" - @method_decorator(never_cache) + @method_decorator(cache_page(1)) def dispatch(self, *args, **kwargs): """Prevent caching when printing report templates""" return super().dispatch(*args, **kwargs)