1

I want to load photourl from buffer if no change, but it works only after first refresh of page. When I open page for first time this is my response

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

after refresh i have 304 status and response:

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

and in request

If-Modified-Since Thu, 18 Aug 2016 09:56:55 GMT

after another refresh i have 200 status like on first visit and data are reloaded from server.

This is my controller.

@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();            

}
lassa
  • 173
  • 9

0 Answers0