如果没有更改,我想从缓冲区加载 photourl,但它仅在第一次刷新页面后才有效。当我第一次打开页面时,这是我的回应
Cache-Control no-cache
Content-Length 12279
Content-Type text/plain
Date Thu, 18 Aug 2016 10:26:45 GMT
Expires Mon, 01 Jan 1990 00:00:00 GMT
Last-Modified Thu, 18 Aug 2016 09:56:55 GMT
Server Development/1.0
刷新后我有 304 状态和响应:
Cache-Control no-cache, no-store, max-age=0, must-revalidate
Date Thu, 18 Aug 2016 10:29:21 GMT
Expires 0
Last-Modified Thu, 18 Aug 2016 09:56:55 GMT
Pragma no-cache
Server Development/1.0
X-Frame-Options DENY
X-XSS-Protection 1; mode=block
x-content-type-options nosniff
并应要求
If-Modified-Since Thu, 18 Aug 2016 09:56:55 GMT
再次刷新后,我有 200 个状态,例如第一次访问,并且从服务器重新加载数据。
这是我的控制器。
@ResponseBody
@RequestMapping(value = "/photo", produces = "text/plain", method = RequestMethod.GET)
public String myPhoto(HttpServletResponse response, WebRequest request) {
Photo photo = photoService.getPhoto();
long lastModified = photo.getModificationDate().getTime();
if (request.checkNotModified(lastModified)) {
return null;
}
return photo.photoURL();
}