Prentice Hall and Sun Microsystems. Personal use only; do not redistribute.
7.2 HTTP 1.1 Response Headers and Their Meaning
151
for a document that changes relatively frequently, to prevent the 
browser from displaying a stale cached value. For example, the follow 
ing would instruct the browser not to cache the document for longer 
than 10 minutes
long currentTime = System.currentTimeMillis();
long tenMinutes = 10*60*1000; // In milliseconds
response.setDateHeader("Expires", 
currentTime + tenMinutes);
Also see the 
max age
 value of the 
Cache Control
 header.
Last Modified
This very useful header indicates when the document was last changed. 
The client can then cache the document and supply a date by an 
If Mod 
ified Since
 request header in later requests. This request is treated as 
a conditional 
GET
, with the document only being returned if the 
Last Modified
 date is later than the one specified for 
If Modi 
fied Since
. Otherwise, a 304 (
Not Modified
) status line is returned, 
and the client uses the cached document. If you set this header explicitly, 
use the 
setDateHeader
 method to save yourself the bother of formatting 
GMT date strings. However, in most cases you simply implement the 
getLastModified
 method and let the standard 
service
 method handle 
If Modified Since
 requests. For an example, see Section 2.8 (An 
Example Using Servlet Initialization and Page Modification Dates).
Location
This header, which should be included with all responses that have a sta 
tus code in the 300s, notifies the browser of the document address. The 
browser automatically reconnects to this location and retrieves the new 
document. This header is usually set indirectly, along with a 302 status 
code, by the 
sendRedirect
 method of 
HttpServletResponse
. An 
example is given in Section 6.3 (A Front End to Various Search Engines).
Pragma
Supplying this header with a value of 
no cache
 instructs HTTP 1.0 cli 
ents not to cache the document. However, support for this header was 
inconsistent with HTTP 1.0 browsers. In HTTP 1.1,  
Cache Control: 
no cache
  is a more reliable replacement.
Second edition of this book: www.coreservlets.com; Sequel: www.moreservlets.com.
Servlet and JSP training courses by book's author: courses.coreservlets.com.






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

jsp web hosting

 

Our partners: PHP: Hypertext Preprocessor Best Web Hosting Java Web Hosting Jsp Web Hosting Cheapest Web Hosting

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved