I am trying to customize serving of some static resources with renderBinary().
I would like to serve these assets through controller which optionaly checks
authorization and serves appropriate file.
I would also like to cache some file for 1 year as they never change.
The method in my controller looks something like this:
public static void item(String item) {
// check authorization ...
response.cacheFor("365d");
renderBinary(Play.getFile("static/" + item));
}
The problem I am having is that play automatically adds Etag and
caches it for 1 hour when using renderBinary, so the net effect is that
firefox re-issues request for these files again when needed, only to get
304 response from play server.
I know I can achieve thing with nginx as frontend but would like to do it
using only play.
This is a known bug in Play, see https://play.lighthouseapp.com/projects/57987-play-framework/tickets/772-overwritten-of-cache-control-header-when-apply-renderbinary-to-a-file