Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

getLastModified  RSS feed

 
Parameswaran Thangavel
Ranch Hand
Posts: 485
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all
i didn't get what the above method meant by,
when i refer to some site it suggest to override this method

can any explain me???
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think the easiest way to understand this would be to download and install
the HTTPLiveHeaders plugin for Firefox:
http://livehttpheaders.mozdev.org/

Then with it running click through a few familiar sites (this one for instance). You will see in the request headers, something like this:


This is the browser telling the server that "I've already got a copy of this resource in my cache. Let me know if you have a newer copy"

In the response headers, you will then see something like:

This is the server replying with "The one I have is no newer than the one in your cache, use that one.

The server is saved the burden of sending something that the browser already has.

If you override HttpServlet.getLastModified and use it correctly in your servlets, you could potentially save your servlet a lot of work.

Let's suppose you have a page of "Daily Specials" in an e-commerce site and let's suppose it takes a lot of work to compile this list (several database operations). If you update the getLastModified only when this list changes and you compare this value with the value sent in the If-Modified-Since header with each request, you could avoid making repeated database calls over and over for the same user.

Unfortunately, there is usually other dynamic content on such pages that would be foiled by client side caching. For this reason, most people opt to cache lists like this on the server and use that to regenerate the page.
 
Makarand Parab
Ranch Hand
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ben Souther
That was really a good explantion.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!