public static void getPhoto(String userId) {
Logger.debug("GETPHOTO");
Usuario connectedUser = Usuario.getById(Security.connected());
Usuario u = Usuario.getById(userId);
notFoundIfNull(u);
if (!u.canView(connectedUser))
forbidden();
response.setHeader("Cache-Control", "no-cache");
renderBinary(u.getPhoto());
}
But, the response of Play! server was this:
Cache-Control:max-age=3600
Content-Disposition:inline;
filename*=utf-8''8e055b51-49f2-490e-93bf-454a2f1c2eeb.jpg;
filename="8e055b51-49f2-490e-93bf-454a2f1c2eeb.jpg"
Content-Type:image/jpeg
ETag:"1288884338000-1691088053"
Server:Play! Framework;1.1;prod
What's going on?
El día 4 de febrero de 2011 15:51, Ivan San José García
<iva...@gmail.com> escribió:
--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To post to this group, send email to play-fr...@googlegroups.com.
To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.
I think that addEtag() method override my Cache-Control header in prod mode:
When renderBinary() is applied to a File object, the method addEtag()
was called in PlayHandler class:
private static HttpResponse addEtag(HttpRequest nettyRequest,
HttpResponse httpResponse, File file) {
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);
}
}
And there, in production mode, overwrites any Cache-Control header
that was setted with request.setHeader() in a Controller.
Is this a bug?
2011/2/4 Pascal Voitot Dev <pascal.v...@gmail.com>:
Additionally, I think that Play! doesn't handle well the ETag header.
See this situation:
- Request:
If-None-Match:"1296821490000--1382045956"
- Response:
200 OK
ETag:"1296821490000--1382045956"
I think this is wrong. Because, if the content requested didn't
change, Play! must response with a 304 Not Modified, and not with the
same content again.
I'm wrong or it's a bug? I'm using Play! 1.1.
El día 4 de febrero de 2011 16:43, Ivan San José García
Although, the bug about that "Cache-Control" was overwritten when use
renderBinary(), is true. So, I have created a ticket with a patch:
http://play.lighthouseapp.com/projects/57987-play-framework/tickets/772-overwritten-of-cache-control-header-when-apply-renderbinary-to-a-file
El día 7 de febrero de 2011 09:20, Ivan San José García