Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
renderBinary responses always has "no-cache" headers when packaged as WAR #1206
We noticed that renderBinary(file) behaves differently when Play is run via the Play server and when it is packaged as WAR and used in an app server (Jetty or Tomcat).
The behaviour is correct when running Play in prod mode, the Cache-Control headers are correctly added.
The code to reproduce the issue is quite simple
The difference in behaviour comes from the fact that the code for serving binary file uses PlayHandler.java when using the Play server, and ServletWrapper.java when using a WAR file.
ServletWrapper.java only reads the configuration for "serveStatic", but not in copyResponse:
There is a simple workaround, just by using cacheFor on the response
long last = file.lastModified(); String etag = "\"" + last + "-" + file.hashCode() + "\""; response.cacheFor(etag, "30d", last); renderBinary(file);
But I believe it should be fixed in ServletWrapper directly