Correction on cache

This commit is contained in:
loulous27 2025-12-04 16:47:23 +01:00
parent 59860c3e37
commit 37220efe96
3 changed files with 5 additions and 5 deletions

View file

@ -28,7 +28,7 @@ BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
SECRET_KEY = "CHANGE ME"
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
DEBUG = True
ALLOWED_HOSTS = [
"127.0.0.1",

View file

@ -6,17 +6,17 @@ from django.contrib.auth import get_user_model
from django.contrib.auth.mixins import LoginRequiredMixin
from django.http import HttpResponse
from django.views.generic import ListView, View
from django.views.decorators.cache import cache_page
from photologue.models import Gallery
class MediaAccess(LoginRequiredMixin, View):
@cache_page(31*24*60*60)
def get(self, request, path):
response = HttpResponse()
# Content-type will be detected by nginx
del response["Content-Type"]
response["X-Accel-Redirect"] = "/protected/media/" + path
response['Cache-Control'] = 'max-age=%d' % 60*60*24*31
return response