Skip to content

Commit

Permalink
Including both Cache-Control and Expires headers apparently isn't red…
Browse files Browse the repository at this point in the history
…undant.

This reverts commit 6055f0d.
  • Loading branch information
magnars committed Dec 28, 2013
1 parent 659884d commit e024fa6
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
Expand Up @@ -22,6 +22,7 @@
(subs (digest/sha-1 (get-contents file)) 0 12) (subs (digest/sha-1 (get-contents file)) 0 12)
(:path file))) (:path file)))
(assoc :original-path (original-path file)) (assoc :original-path (original-path file))
(assoc-in [:headers "Cache-Control"] "max-age=315360000")
(assoc-in [:headers "Expires"] (http-date-formatter (time/plus (time/now) (assoc-in [:headers "Expires"] (http-date-formatter (time/plus (time/now)
(time/days 3650)))))) (time/days 3650))))))


Expand Down
Expand Up @@ -22,7 +22,8 @@
{:path "/f549e6e556ea/code.js" {:path "/f549e6e556ea/code.js"
:original-path "/code.js" :original-path "/code.js"
:contents "1 + 2" :contents "1 + 2"
:headers {"Expires" "Fri, 28 Jul 2023 00:00:00 GMT"}}]) :headers {"Cache-Control" "max-age=315360000"
"Expires" "Fri, 28 Jul 2023 00:00:00 GMT"}}])


(fact (fact
"While it's important that the :original-path property is set, so "While it's important that the :original-path property is set, so
Expand All @@ -45,6 +46,7 @@
(map (juxt :path :headers))) (map (juxt :path :headers)))
=> [["/c.js" {"Last-Modified" "Fri, 28 Jul 2023 00:00:00 GMT"}] => [["/c.js" {"Last-Modified" "Fri, 28 Jul 2023 00:00:00 GMT"}]
["/f549e6e556ea/c.js" {"Last-Modified" "Fri, 28 Jul 2023 00:00:00 GMT" ["/f549e6e556ea/c.js" {"Last-Modified" "Fri, 28 Jul 2023 00:00:00 GMT"
"Cache-Control" "max-age=315360000"
"Expires" "Fri, 28 Jul 2023 00:00:00 GMT"}]]) "Expires" "Fri, 28 Jul 2023 00:00:00 GMT"}]])


(fact (fact
Expand Down
3 changes: 2 additions & 1 deletion test/optimus/optimizations_test.clj
Expand Up @@ -6,7 +6,8 @@
(:use midje.sweet)) (:use midje.sweet))


(with-redefs [time/now (fn [] (time/date-time 2013 07 30))] (with-redefs [time/now (fn [] (time/date-time 2013 07 30))]
(def headers {"Expires" "Fri, 28 Jul 2023 00:00:00 GMT"}) (def headers {"Cache-Control" "max-age=315360000"
"Expires" "Fri, 28 Jul 2023 00:00:00 GMT"})


(fact (fact
"This is a big integration test, for sure. It bundles bundles, it "This is a big integration test, for sure. It bundles bundles, it
Expand Down
4 changes: 2 additions & 2 deletions test/optimus/strategies_test.clj
Expand Up @@ -22,10 +22,10 @@
"Headers are included." "Headers are included."


(defn get-assets [] (defn get-assets []
[{:path "/more.js" :contents "3 + 4" :headers {"Expires" "Fri, 28 Jul 2023 00:00:00 GMT"}}]) [{:path "/more.js" :contents "3 + 4" :headers {"Cache-Control" "max-age=315360000"}}])


(let [app (serve-live-assets noop get-assets dont-optimize {})] (let [app (serve-live-assets noop get-assets dont-optimize {})]
(app {:uri "/more.js"}) => {:status 200 :body "3 + 4" :headers {"Expires" "Fri, 28 Jul 2023 00:00:00 GMT"}})) (app {:uri "/more.js"}) => {:status 200 :body "3 + 4" :headers {"Cache-Control" "max-age=315360000"}}))


(fact (fact
"Assets are fetched for each request. We wouldn't want to restart the "Assets are fetched for each request. We wouldn't want to restart the
Expand Down

0 comments on commit e024fa6

Please sign in to comment.