You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@storm.apache.org by pt...@apache.org on 2016/07/21 17:27:30 UTC
[04/13] storm git commit: STORM-1890: add code Cache-Control:
no-cache to root html pages (/*.html)
STORM-1890: add code Cache-Control: no-cache to root html pages (/*.html)
Signed-off-by: P. Taylor Goetz <pt...@gmail.com>
Project: http://git-wip-us.apache.org/repos/asf/storm/repo
Commit: http://git-wip-us.apache.org/repos/asf/storm/commit/44e81709
Tree: http://git-wip-us.apache.org/repos/asf/storm/tree/44e81709
Diff: http://git-wip-us.apache.org/repos/asf/storm/diff/44e81709
Branch: refs/heads/1.0.x-branch
Commit: 44e817092241613f5849ec6e8b6a84a034a2bb0e
Parents: b52172b
Author: Alessandro Bellina <ab...@yahoo-inc.com>
Authored: Sat Jun 18 14:05:27 2016 -0500
Committer: P. Taylor Goetz <pt...@gmail.com>
Committed: Thu Jul 21 12:14:18 2016 -0400
----------------------------------------------------------------------
.../src/clj/org/apache/storm/ui/helpers.clj | 22 ++++++++++++++++----
1 file changed, 18 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/storm/blob/44e81709/storm-core/src/clj/org/apache/storm/ui/helpers.clj
----------------------------------------------------------------------
diff --git a/storm-core/src/clj/org/apache/storm/ui/helpers.clj b/storm-core/src/clj/org/apache/storm/ui/helpers.clj
index 7ded154..81ceb58 100644
--- a/storm-core/src/clj/org/apache/storm/ui/helpers.clj
+++ b/storm-core/src/clj/org/apache/storm/ui/helpers.clj
@@ -32,18 +32,32 @@
[org.eclipse.jetty.util.ssl SslContextFactory]
[org.eclipse.jetty.server DispatcherType]
[org.eclipse.jetty.servlets CrossOriginFilter])
- (:require [ring.util servlet])
+ (:require [ring.util servlet]
+ [ring.util.response :as response])
(:require [compojure.route :as route]
[compojure.handler :as handler])
(:require [metrics.meters :refer [defmeter mark!]]))
(defmeter num-web-requests)
+
(defn requests-middleware
- "Coda Hale metric for counting the number of web requests."
+ "Wrap request with Coda Hale metric for counting the number of web requests,
+ and add Cache-Control: no-cache for html files in root directory (index.html, topology.html, etc)"
[handler]
(fn [req]
- (mark! num-web-requests)
- (handler req)))
+ (.mark num-web-requests)
+ (let [uri (:uri req)
+ res (handler req)
+ content-type (response/get-header res "Content-Type")]
+ ;; check that the response is html and that the path is for a root page: a single / in the path
+ ;; then we know we don't want it cached (e.g. /index.html)
+ (if (and (= content-type "text/html")
+ (= 1 (count (re-seq #"/" uri))))
+ ;; response for html page in root directory, no-cache
+ (response/header res "Cache-Control" "no-cache")
+ ;; else, carry on
+ res))))
+
(defn split-divide [val divider]
[(Integer. (int (/ val divider))) (mod val divider)]