From faaaacfce6941438e5911dc9c207208213f211b4 Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Sun, 26 Feb 2012 02:45:02 +0100 Subject: Add Cache-Control: no-cache to the default response headers. --- src/mulk/benki/main.clj | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/mulk/benki/main.clj b/src/mulk/benki/main.clj index 09def98..2135b6f 100644 --- a/src/mulk/benki/main.clj +++ b/src/mulk/benki/main.clj @@ -26,9 +26,17 @@ (hiccup.core/with-base-url base-uri ((noir.options/wrap-options handler {:base-url base-uri}) request))))) +(defn wrap-cache-control [handler] + (fn [request] + (let [response (handler request)] + (if (get-in response [:headers "Cache-Control"]) + response + (assoc-in response [:headers "Cache-Control"] "no-cache"))))) + (do-once ::init (noir.server/add-middleware #(wrap-utf-8 %)) (noir.server/add-middleware #(wrap-base-uri %)) + (noir.server/add-middleware #(wrap-cache-control %)) (noir.server/add-middleware #(ring.middleware.file/wrap-file % "static"))) (defonce server (doto (Thread. #(noir.server/start (:web-port @benki-config))) -- cgit v1.2.3