瀏覽代碼

Fixes #12760 - Adds Vary header to cause cache to be keyed based on URL and the HX-Request header (or lack thereof)

Daniel Sheppard 2 年之前
父節點
當前提交
f69d99ea67
共有 1 個文件被更改,包括 3 次插入0 次删除
  1. 3 0
      netbox/netbox/middleware.py

+ 3 - 0
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