Files
customerTicket/apps/core/middleware.py
T
2026-09-10 11:34:19 +03:30

14 lines
546 B
Python

class NoStoreHTMLMiddleware:
"""Prevent browsers and installed PWAs from retaining authenticated HTML views."""
def __init__(self, get_response):
self.get_response = get_response
def __call__(self, request):
response = self.get_response(request)
if response.get("Content-Type", "").lower().startswith("text/html"):
response["Cache-Control"] = "private, no-cache, no-store, must-revalidate"
response["Pragma"] = "no-cache"
response["Expires"] = "0"
return response