From f69d99ea67c503d481ac8a3b6c1213be99db9990 Mon Sep 17 00:00:00 2001 From: Daniel Sheppard Date: Tue, 27 Jun 2023 08:48:27 -0500 Subject: [PATCH] Fixes #12760 - Adds Vary header to cause cache to be keyed based on URL and the HX-Request header (or lack thereof) --- netbox/netbox/middleware.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/netbox/netbox/middleware.py b/netbox/netbox/middleware.py index ba6967f1f..18f350fd7 100644 --- a/netbox/netbox/middleware.py +++ b/netbox/netbox/middleware.py @@ -49,6 +49,9 @@ class CoreMiddleware: # Attach the unique request ID as an HTTP header. response['X-Request-ID'] = request.id + # Enable the Vary header to help with caching of HTMX responses + response['Vary'] = 'HX-Request' + # If this is an API request, attach an HTTP header annotating the API version (e.g. '3.5'). if is_api_request(request): response['API-Version'] = settings.REST_FRAMEWORK_VERSION