You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Ralph Einfeldt <ra...@uptime-isc.de> on 2001/12/11 07:53:35 UTC

AW: Apache + mod_jk (ajp13) + Tomcat: no "Expires" header in the response

Is mod_expire enabled on the linux box ?

AFAIK apache won't set the expires header unless you use mod_expire.

To enable expiring you have to do it on your own:
<%
  response.setHeader("Cache-Control","no-cache"); //HTTP 1.1
  response.setHeader("Pragma","no-cache"); //HTTP 1.0
  response.setDateHeader("Expires", 0); //prevents caching at the proxy
server
%>

> -----Ursprüngliche Nachricht-----
> Von: Michele Milani [mailto:michele.milani@cefriel.it]
> Gesendet: Montag, 10. Dezember 2001 18:23
> An: 'tomcat-user@jakarta.apache.org'
> Betreff: RE: Apache + mod_jk (ajp13) + Tomcat: no "Expires" header in
> the response
> 
> 
> This stuff is getting *really* funny! I run it under Windows 
> and it worked.
> I compared HTTP headers, the problem is that:
> 
>  - Apache (under Windows or Linux) does not set "Expires" 
> header for HTML
> pages restituted by Tomcat
>  - Apache _under Linux_ sets a wrong (i.e. old, not updated) 
> "Last-Modified"
> header, so that the browser loads a local cached copy of the page
> 
> The time set by Apache into the "Last-Modified" header is not 
> the time of
> creation/modification of any other file of my webapps/test 
> directory, so I
> really can't understand how Apache sets it.
> 
> Any hint?
> 
> Cheers,
> Michele
> 
> > -----Original Message-----
> > From: Michele Milani 
> > Sent: lunedì 10 dicembre 2001 12:14
> > To: 'tomcat-user@jakarta.apache.org'
> > Subject: Apache + mod_jk (ajp13) + Tomcat: no "Expires" 
> header in the
> > response
> > 
> > 
> > Dear guys,
> > 
> > I searched the archive and the Usenet without success.
> > 
> > I'm using a box with:
> > 
> >  - Linux Red Hat 7.2
> >  - Apache 1.3.20
> >  - mod_jk (ajp13)
> >  - Tomcat 3.3
> > 
> > I developed a web application that let you browse through 
> > some static HTML pages and let you update the content of 
> > these HTML page, inserting some data in a form.
> > 
> > The update of the static pages is done by a servlet that 
> > rewrite the HTML file. The problem is that I can't get the 
> > last updated HTML page in my browser.
> > 
> > I thought it was a problem realted to caching, so I forced 
> > Apache to set the "Expires" header writing in the httpd.conf:
> > 
> > #ExpiresActive On
> > #ExpiresByType text/html "access"
> > 
> > but this solution didn't help.
> > 
> > I turned on a protocol analyzer (Etheral) to try and 
> > understand what the problem was and I realized that Apache 
> > does not set the "Expires" header when the HTML page comes 
> > from Tomcat.
> > 
> > I think my application is not so strange: I want to save the 
> > new data inserted by the user so that the next time she 
> > requests the page she gets the last version of it.
> > 
> > I wrote another very simple application to explain my problem 
> > better, simply copy the following files under 
> > $TOMCAT_HOME/webapps/ and compile the servlet:
> > 
> > ===============
> > test/index.html
> > ===============
> > <html>
> > <head>
> > </head>
> > <body>
> > <a href="servlet/DateServlet">Test</a><br>
> > </body>
> > </html>
> > 
> > =====================================
> > test/WEB-INF/classes/DateServlet.java
> > =====================================
> > import java.io.*;
> > import java.util.*;
> > import javax.servlet.*;
> > import javax.servlet.http.*;
> > 
> > public class DateServlet extends HttpServlet {
> > 	
> > 	public void doGet(HttpServletRequest request, 
> > HttpServletResponse response) throws IOException, ServletException {
> > 		try {
> > 			Date now = new Date();
> > 			
> > 			PrintWriter dateWriter = new 
> > PrintWriter(new FileWriter("../webapps/test/date.html"), true);
> > 			dateWriter.println(now);
> > 			dateWriter.println("<br>");
> > 			dateWriter.println("<a 
> > href=\"servlet/DateServlet\">Update</a>");
> > 			dateWriter.close();
> > 			
> > 			response.setContentType("text/html");
> > 			PrintWriter out = response.getWriter();
> > 			out.println(now);
> > 			out.println("<meta http-equiv='refresh' 
> > content='3; url=\"/test/date.html\"'></meta>");
> > 			
> > 		} catch(Exception ex) {
> > 			PrintWriter errorWriter = new 
> > PrintWriter(new FileWriter("../webapps/bib/error.txt"), true);
> > 			ex.printStackTrace(errorWriter);
> > 			errorWriter.close();
> > 		}
> > 	}
> > 	
> > }
> > 
> > Did anyone else experiment such problems?
> > 
> > Cheers,
> > Michele
> > 
> 
> --
> To unsubscribe:   <ma...@jakarta.apache.org>
> For additional commands: <ma...@jakarta.apache.org>
> Troubles with the list: <ma...@jakarta.apache.org>
> 
> 
> 

--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>