| Author |
Set Reponse Headers Problem
|
Edmund Yong
Ranch Hand
Joined: Nov 16, 2003
Posts: 164
|
|
I wrote the following filter and use it on WebLogic Server 8.1: I want to set all HTTP responses with Cache-Control set to no-cache. For JSPs, it works ok. For images and style sheets, the server will set the Last-Modified header again after I have set it to 1970. For Cache-Control, the server will remove it if it sets Last-Modified. It seems that Last-Modified and Cache-Control do not work together; you can only have one but not both. What can I do? I want all responses to have Cache-Control set to no-cache. If Last-Modified is set, than Cache-Control is removed by server. I can't remove Last-Modified or change its value.
|
SCJP 1.2, SCWCD 1.4
|
 |
Biba Basnetti
Greenhorn
Joined: Oct 09, 2006
Posts: 25
|
|
I am studying for the SCWCD so maybe I don't know what the hell I am talking about but....
filterChain.doFilter(req, res); if (res.containsHeader("Last-Modified")) { res.setDateHeader("Last-Modified", 0); } res.setHeader("Cache-Control", "no-cache");
why are you calling the filterChain's doFilter method before you set the response headers? I think when you call the filterChain.doFilter() method the req,res goes through the filters stack and eventually to the servlet going to the browser. Setting the response headers after the filterChain.doFilter() should have no effect.
|
 |
Edmund Yong
Ranch Hand
Joined: Nov 16, 2003
Posts: 164
|
|
You are wrong. It does have an effect. Looks like you need to study more.
|
 |
 |
|
|
subject: Set Reponse Headers Problem
|
|
|