Correction on cache
This commit is contained in:
parent
e644778673
commit
25eed7ef78
1 changed files with 2 additions and 2 deletions
|
|
@ -6,17 +6,17 @@ from django.contrib.auth import get_user_model
|
||||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||||
from django.http import HttpResponse
|
from django.http import HttpResponse
|
||||||
from django.views.generic import ListView, View
|
from django.views.generic import ListView, View
|
||||||
from django.views.decorators.cache import cache_page
|
|
||||||
from photologue.models import Gallery
|
from photologue.models import Gallery
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class MediaAccess(LoginRequiredMixin, View):
|
class MediaAccess(LoginRequiredMixin, View):
|
||||||
@cache_page(31*24*60*60)
|
|
||||||
def get(self, request, path):
|
def get(self, request, path):
|
||||||
response = HttpResponse()
|
response = HttpResponse()
|
||||||
# Content-type will be detected by nginx
|
# Content-type will be detected by nginx
|
||||||
del response["Content-Type"]
|
del response["Content-Type"]
|
||||||
response["X-Accel-Redirect"] = "/protected/media/" + path
|
response["X-Accel-Redirect"] = "/protected/media/" + path
|
||||||
|
response['Cache-Control'] = 'max-age=%d' % 60*60*24*31
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue