You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Shireesh Thanneru <th...@yahoo.com> on 2003/05/23 00:27:12 UTC

Cache Settings in server.xml

Is there a way to set page cache settings on a URL pattern basis or on a
global basis in Tomcat (4.1.x)?

For example, with Resin, we can do something like:

<cache-mapping url-pattern='*.jspa' expires='1d'/>

Is there an equivalent setting in Tomcat either in server.xml or in any
other configuration files?

Thanks,

Shireesh Thanneru


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


RE: Cache Settings in server.xml

Posted by Shireesh Thanneru <th...@yahoo.com>.
Thanks.

Shireesh Thanneru

-----Original Message-----
From: Tim Funk [mailto:funkman@joedog.org]
Sent: Friday, May 23, 2003 7:45 AM
To: Tomcat Users List
Subject: Re: Cache Settings in server.xml


In that case, no. An "easy" around that is to create a filter which does
that
for you. That way, you are webapp container independent.

Simplistic examle:

package more.cowbell;

import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletResponse;

public class NoCacheFilter implements Filter {
     public void init(FilterConfig filterConfig) {}

     public void doFilter(ServletRequest request,
		         ServletResponse response,
		         FilterChain chain)
			   throws IOException,
			          ServletException {
		((HttpServletResponse)response).setDateHeader("Expires", 0);
		chain.doFilter( request, response);
	}

     public void destroy() { }
}

then in web.xml:
   <filter>
     <filter-name>noCacheFilter</filter-name>
     <description>Make sure my pages don't get client cached</description>
     <filter-class>more.cowbell.NoCacheFilter</filter-class>
   </filter>

   <filter-mapping>
     <filter-name>noCacheFilter</filter-name>
     <url-pattern>*.jsp</url-pattern>
   </filter-mapping>


-Tim

Shireesh Thanneru wrote:
> I am not asking about caching pages on the server side. What I am asking
for
> is a tomcat setting, which when set, will cause Tomcat to send the
> corresponding header when that page is requested. For example, when you
set
> something like:
>
> <cache-mapping url-pattern='*.jsp' expires='0'/>
>
> Tomcat should automatically send a response header something like (so that
> the client/browser gets this header and behaves accordingly):
>
> response.setDateHeader ("Expires", 0);
>
> for all the requested pages that match the url-pattern above. This way,
you
> don't have to set this header in each of your pages and can be changed
with
> out changing the source code.
>
> So, the question really is: Does Tomcat have such a setting?
>
> Thanks,
>
> Shireesh Thanneru


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Cache Settings in server.xml

Posted by Tim Funk <fu...@joedog.org>.
In that case, no. An "easy" around that is to create a filter which does that 
for you. That way, you are webapp container independent.

Simplistic examle:

package more.cowbell;

import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletResponse;

public class NoCacheFilter implements Filter {	
     public void init(FilterConfig filterConfig) {}

     public void doFilter(ServletRequest request,
		         ServletResponse response,
		         FilterChain chain)
			   throws IOException,
			          ServletException {
		((HttpServletResponse)response).setDateHeader("Expires", 0);
		chain.doFilter( request, response);
	}

     public void destroy() { }
}

then in web.xml:
   <filter>
     <filter-name>noCacheFilter</filter-name>
     <description>Make sure my pages don't get client cached</description>
     <filter-class>more.cowbell.NoCacheFilter</filter-class>
   </filter>

   <filter-mapping>
     <filter-name>noCacheFilter</filter-name>
     <url-pattern>*.jsp</url-pattern>
   </filter-mapping>


-Tim

Shireesh Thanneru wrote:
> I am not asking about caching pages on the server side. What I am asking for
> is a tomcat setting, which when set, will cause Tomcat to send the
> corresponding header when that page is requested. For example, when you set
> something like:
> 
> <cache-mapping url-pattern='*.jsp' expires='0'/>
> 
> Tomcat should automatically send a response header something like (so that
> the client/browser gets this header and behaves accordingly):
> 
> response.setDateHeader ("Expires", 0);
> 
> for all the requested pages that match the url-pattern above. This way, you
> don't have to set this header in each of your pages and can be changed with
> out changing the source code.
> 
> So, the question really is: Does Tomcat have such a setting?
> 
> Thanks,
> 
> Shireesh Thanneru


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


RE: Cache Settings in server.xml

Posted by Shireesh Thanneru <th...@yahoo.com>.
I am not asking about caching pages on the server side. What I am asking for
is a tomcat setting, which when set, will cause Tomcat to send the
corresponding header when that page is requested. For example, when you set
something like:

<cache-mapping url-pattern='*.jsp' expires='0'/>

Tomcat should automatically send a response header something like (so that
the client/browser gets this header and behaves accordingly):

response.setDateHeader ("Expires", 0);

for all the requested pages that match the url-pattern above. This way, you
don't have to set this header in each of your pages and can be changed with
out changing the source code.

So, the question really is: Does Tomcat have such a setting?

Thanks,

Shireesh Thanneru

-----Original Message-----
From: Tim Funk [mailto:funkman@joedog.org]
Sent: Thursday, May 22, 2003 7:40 PM
To: Tomcat Users List
Subject: Re: Cache Settings in server.xml


Tomcat doesn't come with page caching. There is a jakarta taglib project
which does do caching (but can't comment on how good/stable/mature it is)
and
I imagine there are other projects floating somewhere which also performs
caching.

-Tim

Shireesh Thanneru wrote:
> Is there a way to set page cache settings on a URL pattern basis or on a
> global basis in Tomcat (4.1.x)?
>
> For example, with Resin, we can do something like:
>
> <cache-mapping url-pattern='*.jspa' expires='1d'/>
>
> Is there an equivalent setting in Tomcat either in server.xml or in any
> other configuration files?
>
> Thanks,
>
> Shireesh Thanneru
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: Cache Settings in server.xml

Posted by Tim Funk <fu...@joedog.org>.
Tomcat doesn't come with page caching. There is a jakarta taglib project 
which does do caching (but can't comment on how good/stable/mature it is) and 
I imagine there are other projects floating somewhere which also performs 
caching.

-Tim

Shireesh Thanneru wrote:
> Is there a way to set page cache settings on a URL pattern basis or on a
> global basis in Tomcat (4.1.x)?
> 
> For example, with Resin, we can do something like:
> 
> <cache-mapping url-pattern='*.jspa' expires='1d'/>
> 
> Is there an equivalent setting in Tomcat either in server.xml or in any
> other configuration files?
> 
> Thanks,
> 
> Shireesh Thanneru
> 
>  


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org