我正在尝试使用ShallowEtagHeaderFilter在我的springboot中实现ETAG:
@Bean
public ShallowEtagHeaderFilter shallowEtagHeaderFilter() {
System.out.println(new ShallowEtagHeaderFilter());
return new ShallowEtagHeaderFilter();
}
当我做
之类的事情时,我在标题中显示了ETAGcurl -i -X POST localhost:8080/search/XLT
但是当我向前一个收到的etag请求来源时,我无法再看到它了:
curl -i -X POST localhost:8080/search/XLT -H 'If-None-Match:"MY PREVIOUS REQ ETAG MD5"
也无法看到304 Not Modified和任何其他响应。
MY GET METHOD
//USER Get REQUEST
@RequestMapping(value = "/user/{user_id}", method = RequestMethod.GET)
public @ResponseBody String getReport(
@PathVariable("user_id") String userid,
HttpServletRequest request,
HttpServletResponse response) {
//Adding request type to responseList
addResponse(true, "<HTTP-GET REQUEST>");
//Call ProcessGetRequest which will return data fetched with that key
ProcessGetRequest(userid);
return displayResponseStatus();
}
我有什么遗漏的东西吗? 任何帮助将不胜感激。
答案 0 :(得分:1)
ShallowEtagHeaderFilter
仅适用于GET和HEAD请求,它是支持ETag的粗略方式。
根据您对CRUD服务进行编码的方式,使用ResponseEntity
或WebRequest
对supports higher-level features for such cases进行编码。