mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-04 00:42:16 +02:00
Set Cache-Control: no-cache on every response
This commit is contained in:
parent
093c34a787
commit
0dd158bdd8
2 changed files with 19 additions and 0 deletions
|
@ -136,6 +136,8 @@ MIDDLEWARE = [
|
|||
"allow_cidr.middleware.AllowCIDRMiddleware",
|
||||
# django-cors-headers: listen to cors responses
|
||||
"corsheaders.middleware.CorsMiddleware",
|
||||
# custom middleware to stop caching from CloudFront
|
||||
"registrar.no_cache_middleware.NoCacheMiddleware",
|
||||
# serve static assets in production
|
||||
"whitenoise.middleware.WhiteNoiseMiddleware",
|
||||
# provide security enhancements to the request/response cycle
|
||||
|
|
17
src/registrar/no_cache_middleware.py
Normal file
17
src/registrar/no_cache_middleware.py
Normal file
|
@ -0,0 +1,17 @@
|
|||
"""Middleware to add Cache-control: no-cache to every response.
|
||||
|
||||
Used to force Cloudfront caching to leave us alone while we develop
|
||||
better caching responses.
|
||||
"""
|
||||
|
||||
class NoCacheMiddleware:
|
||||
|
||||
"""Middleware to add a single header to every response."""
|
||||
|
||||
def __init__(self, get_response):
|
||||
self.get_response = get_response
|
||||
|
||||
def __call__(self, request):
|
||||
response = self.get_response(request)
|
||||
response["Cache-Control"] = "no-cache"
|
||||
return response
|
Loading…
Add table
Add a link
Reference in a new issue