Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to implement host-header page expires in Tomcat

Status
Not open for further replies.

bkennedy

IS-IT--Management
Aug 13, 2003
3
US
I'm new to Tomcat but am familiar with Apache and IIS. How do you implement page-expiration timeouts in Tomcat, a la "mod_expires" in Apache ? I am having problems with web customers accessing certain dymanic content over a proxy server and need to set the expiration timeout to zero and can't figure it out.

Very confused...
 
read the tomcat docs, about config and server.xml (tomcat config file)
 
Thanks for the tip. You know I never thought of that...oh wait, yes I did, and I didn't find anything on the subject, so I decided to post the question here.

Anyone have anything more helpful than "read the documentation" ?
 
I'm new to Tomcat, so I'm unsure whether there is a configuration to set this. However, I'm using the following in JSP's that seems to solve client caching issues.

1. Place the following in at the start of the JSP
<%
response.setHeader(&quot;Cache-Control&quot;,&quot;no-cache&quot;); //HTTP 1.1
response.setHeader(&quot;Pragma&quot;,&quot;no-cache&quot;); //HTTP 1.0
response.setDateHeader (&quot;Expires&quot;, 0); //prevents caching at the proxy server
%>

2. Place the following inside the <head> block
<META HTTP-EQUIV=&quot;Cache-Control&quot; CONTENT=&quot;no-cache&quot;>
<META HTTP-EQUIV=&quot;Pragma&quot; CONTENT=&quot;no-cache&quot;>
<META HTTP-EQUIV=&quot;Expires&quot; CONTENT=&quot;-1&quot;>

3. Place the following at the bottom of the file just before the </HEAD>
<head>
<META HTTP-EQUIV=&quot;Cache-Control&quot; CONTENT=&quot;no-cache&quot;>
<META HTTP-EQUIV=&quot;Pragma&quot; CONTENT=&quot;no-cache&quot;>
<META HTTP-EQUIV=&quot;Expires&quot; CONTENT=&quot;-1&quot;>

Of course, if your trying to set the expiring for non-jsp content such as images....
 
I solved it. Simple solution: Apache2 with mod_jk. Solves everything, as I now use Apache2 as my HTTP server and let Tomcat act as the servlet engine.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top