SE452: Conditional Get [16/20] ![]() ![]() ![]() |
One thing we can use these headers for is conditional get. When the request header If-Modified-Since is present in a request, it is called a conditional get. The browser sends this header.
Advantage: reduce network traffic and server load.
Web brower (client):
Web server:
A servlet may take advantage of the conditional get.
Explicitly setting the Last-Modified header
long t= System.currentTimeMillis(); response.setDateHeader("Last-Modified", t)
Overriding the getLastModified() method in class HttpServlet
long getLastModified( HttpServletRequest request) { return System.currentTimeMillis(); }