cached_pragma_immutable_rand.py (630B)
1 def main(request, response): 2 # Disable non-standard XSS protection 3 response.headers.set(b"X-XSS-Protection", b"0") 4 response.headers.set(b"Content-Type", b"text/html") 5 6 # Set caching headers with immutable directive 7 # Cache-Control: immutable indicates the resource will never change, 8 # and should be cached even when Pragma: no-cache is present. 9 response.headers.set(b"Cache-Control", b"max-age=2592000, immutable") 10 response.headers.set(b"Pragma", b"no-cache") 11 12 # Include a timestamp to verify caching behavior 13 import time 14 response.content = f"Timestamp: {time.time()}".encode('utf-8')