mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-05 17:28:31 +02:00
Merge pull request #1343 from cisagov/nmb/no-caching
Set Cache-Control: no-cache on every response
This commit is contained in:
commit
652086a771
3 changed files with 23 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
|
||||
|
|
18
src/registrar/no_cache_middleware.py
Normal file
18
src/registrar/no_cache_middleware.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
"""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
|
|
@ -62,6 +62,9 @@
|
|||
10038 OUTOFSCOPE http://app:8080/delete
|
||||
10038 OUTOFSCOPE http://app:8080/withdraw
|
||||
10038 OUTOFSCOPE http://app:8080/withdrawconfirmed
|
||||
10038 OUTOFSCOPE http://app:8080/dns
|
||||
10038 OUTOFSCOPE http://app:8080/dnssec
|
||||
10038 OUTOFSCOPE http://app:8080/dns/dnssec
|
||||
# This URL always returns 404, so include it as well.
|
||||
10038 OUTOFSCOPE http://app:8080/todo
|
||||
# OIDC isn't configured in the test environment and DEBUG=True so this gives a 500 without CSP headers
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue