Github user kishorvpatil commented on a diff in the pull request:
https://github.com/apache/storm/pull/1536#discussion_r70703286
--- Diff: storm-core/src/clj/org/apache/storm/ui/helpers.clj ---
@@ -36,22 +37,35 @@
[org.eclipse.jetty.server DispatcherType]
[org.eclipse.jetty.servlets CrossOriginFilter]
(org.json.simple JSONValue))
- (:require [ring.util servlet])
+ (:require [ring.util servlet]
+ [ring.util.response :as response])
(:require [compojure.route :as route]
[compojure.handler :as handler]))
;; TODO this function and its callings will be replace when ui.core and
logviewer and drpc move to Java
(def num-web-requests (StormMetricsRegistry/registerMeter
"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)))
+ (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 (StringUtils/countMatches uri "/")))
--- End diff --
```(count (re-seq #"/" url))``` could help find the # on "/" in more
clojure like fashion.
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---