From 02f26e07e7e04e016afb63b0a8f5f4c059868001 Mon Sep 17 00:00:00 2001
From: Cal Herries <39073188+calherries@users.noreply.github.com>
Date: Fri, 24 Jun 2022 08:50:10 +1200
Subject: [PATCH] Stop caching /api/geojson/:key requests (#23474)

* Stop caching /api/geojson/:key requests

* Remove extra require
---
 src/metabase/server/request/util.clj | 4 +---
 test/metabase/api/geojson_test.clj   | 5 -----
 2 files changed, 1 insertion(+), 8 deletions(-)

diff --git a/src/metabase/server/request/util.clj b/src/metabase/server/request/util.clj
index 3902e0bb929..0fef21f8a1d 100644
--- a/src/metabase/server/request/util.clj
+++ b/src/metabase/server/request/util.clj
@@ -37,9 +37,7 @@
         (and query-string
              (re-matches #"^/app/dist/.*\.(js|css)$" uri))
         ;; any resource that is named as a cache-busting hex string (e.g. fonts, images)
-        (re-matches #"^/app/dist/[a-f0-9]{20}+.*$" uri)
-        ;; GeoJSON proxy requests should also be cached
-        (re-matches #"^/api/geojson/.*" uri))))
+        (re-matches #"^/app/dist/[a-f0-9]{20}+.*$" uri))))
 
 (defn https?
   "True if the original request made by the frontend client (i.e., browser) was made over HTTPS.
diff --git a/test/metabase/api/geojson_test.clj b/test/metabase/api/geojson_test.clj
index 648d5681c9f..053853932c8 100644
--- a/test/metabase/api/geojson_test.clj
+++ b/test/metabase/api/geojson_test.clj
@@ -4,7 +4,6 @@
             [metabase.api.geojson :as api.geojson]
             [metabase.http-client :as client]
             [metabase.models.setting :as setting]
-            [metabase.server.middleware.security :as mw.security]
             [metabase.test :as mt]
             [metabase.util :as u]
             [metabase.util.schema :as su]
@@ -156,10 +155,6 @@
         (is (= {:type        "Point"
                 :coordinates [37.77986 -122.429]}
                (mt/user-http-request :rasta :get 200 "geojson/middle-earth"))))
-      (testing "response should not include the usual cache-busting headers"
-        (is (= (#'mw.security/cache-far-future-headers)
-               (select-keys (:headers (client/client-full-response :get 200 "geojson/middle-earth"))
-                            (keys (#'mw.security/cache-prevention-headers))))))
       (testing "should be able to fetch the GeoJSON even if you aren't logged in"
         (is (= {:type        "Point"
                 :coordinates [37.77986 -122.429]}
-- 
GitLab