Permalink
Browse files

See https://play.lighthouseapp.com/projects/57987/tickets/772-overwri…

  • Loading branch information...
1 parent f576758 commit 3b031bc8fb1282330e2f07589ed7b838b76d051c Igmar Palsenberg committed Jan 16, 2013
Showing with 10 additions and 7 deletions.
  1. +10 −7 framework/src/play/server/PlayHandler.java
@@ -337,7 +337,7 @@ protected static void addToResponse(Response response, HttpResponse nettyRespons
nettyResponse.addHeader(SET_COOKIE, encoder.encode());
}
- if (!response.headers.containsKey(CACHE_CONTROL) && !response.headers.containsKey(EXPIRES)) {
+ if (!response.headers.containsKey(CACHE_CONTROL) && !response.headers.containsKey(EXPIRES) && !(response.direct instanceof File)) {
nettyResponse.setHeader(CACHE_CONTROL, "no-cache");
}
@@ -886,12 +886,15 @@ private static HttpResponse addEtag(HttpRequest nettyRequest, HttpResponse httpR
if (Play.mode == Play.Mode.DEV) {
httpResponse.setHeader(CACHE_CONTROL, "no-cache");
} else {
- String maxAge = Play.configuration.getProperty("http.cacheControl", "3600");
- if (maxAge.equals("0")) {
- httpResponse.setHeader(CACHE_CONTROL, "no-cache");
- } else {
- httpResponse.setHeader(CACHE_CONTROL, "max-age=" + maxAge);
- }
+ // Check if Cache-Control header is not set
+ if (httpResponse.getHeader(CACHE_CONTROL) == null) {
+ String maxAge = Play.configuration.getProperty("http.cacheControl", "3600");
+ if (maxAge.equals("0")) {
+ httpResponse.setHeader(CACHE_CONTROL, "no-cache");
+ } else {
+ httpResponse.setHeader(CACHE_CONTROL, "max-age=" + maxAge);
+ }
+ }
}
boolean useEtag = Play.configuration.getProperty("http.useETag", "true").equals("true");
long last = file.lastModified();

0 comments on commit 3b031bc

Please sign in to comment.