在播放结果上设置HTTP标头(例如到期)-以及如何处理ETag? [英] Setting HTTP header (like expire) on Play Result - and how to handle ETag?
问题描述
如何在play 2.0的结果对象中设置Http标头?
How can I set Http headers in the result object in play 2.0?
我要这样设置缓存控制(过期): 缓存控制 公众,max-age = 2592000
I want to set Cache control (expire) ala this: Cache-Control PUBLIC, max-age=2592000
检查ET标签并返回正确响应的最佳方法是什么?
What is the best way to check the ET tag and return the correct response ?
一直在这里浏览,但是什么也没看到: http://www.playframework.org/documentation/2.0.1/JavaActions
have been looking through here, but didnt see anything: http://www.playframework.org/documentation/2.0.1/JavaActions
在此先谢谢 托马斯·维维克
In advance thanks thomas vervik
推荐答案
您需要看一下JavaResponse部分...
You need to take a look at the JavaResponse section...
http://www.playframework.org/documentation/2.0.1/JavaResponse
从文档中设置缓存控制的示例是
An example of setting cache control from the documentation is
public static Result index() {
response().setContentType("text/html");
response().setHeader(CACHE_CONTROL, "max-age=3600");
response().setHeader(ETAG, "xxx");
return ok("<h1>Hello World!</h1>");
}
这篇关于在播放结果上设置HTTP标头(例如到期)-以及如何处理ETag?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!