Thanks Balj. Unfortunately using a servlet filter will not serve my purpose. In my system, some requests are proxied from HTTPD to Tomcat while others are served directly by HTTPD. Thus, I am looking for something in the HTTPD layer that can check if the header is already set and then take action accordingly. I am quite sure SetEnvIf directive in conjunction with Header set directive can work here. However, I have not managed to get it working after quite a few tries. Thus I am polling this group to know if someone has already implemented somthing similar. Regards On 3/15/10, Baljeet Nijjhar <baljeet.nijjhar@xxxxxxxxxxxxxx> wrote: > Hi Anurag > I have had the exact same problem and posted in > http://www.gossamer-threads.com/lists/apache/users/382031?page=last > You can use ExpiresDefault/ExpiresByType (this adds both an Expires and > Cache-Control: max-age header to simultaneously support HTTP 1.0 and HTTP > 1.1) or use LocationMatch. For example, I could distinguish between static > content requests (requests to *.gif) vs dynamic content requests > (requests to *.jsp or *.do for a Struts application) using the > LocationMatch. I couldn't find a way of using LocationMatch to work with the > content-type of the response, which was what I needed for file download > requests. Nor could I find a way of checking whether the header was set, > before setting it. (I'm still asking the question). > In the end, I have set the values using e.g. servlet filters in my > application code. > thanks, Balj. > > On Mon, Mar 15, 2010 at 12:50 PM, Anurag Kapur <anuragkapur@xxxxxxxxx>wrote: > >> Hello, >> >> I am looking for some help to set HTTP response headers conditionally. I >> have a setup where HTTPD sits in front of Tomcat and proxies requests to >> it. >> >> *Problem Statement* >> Set a Cache-Control max-age directive in the HTTP response header through >> HTTPD if it doesn't already exist. In addition if HTTPD after detecting >> that >> the directive is not already set in the response header, it should set one >> depending on the response mime-type. >> >> Example: >> HTTPD proxies a request to tomcat -> Tomcat processes the request and send >> back the response to HTTPD -> HTTPD checks if Cache-Control max-age >> directive is set in the response header. If present it does no changes to >> the response header and simply forwards the response back to the user. >> However, if the Cache-Control max-age directive is not present it sets one >> depending on the response mime type (say max-age=900 for text/html and >> max-age=1800 for image/gif) >> * >> * >> *System Info* >> $ apachectl -version >> Server version: Apache/2.2.9 (Unix) >> Server built: Sep 12 2008 16:23:39 >> >> $ uname -a >> SunOS vm-sol10-45 5.10 Generic_127128-11 i86pc i386 i86p >> >> *What I Have Tried* >> I have been trying to work with mod_setenvif module to start but have not >> made any progress and thus seeking your help. >> >> Any inputs would be highly appreciated. >> >> Regards >> Anurag >> * >> *------------------------------------------------------------------ >> Anurag Kapur >> Associate - Technology, >> Sapient Corporation. >> >> http://www.linkedin.com/in/anuragkapur >> >> http://www.google.com/profiles/anuragkapur >> ------------------------------------------------------------------ >> > -- Sent from my mobile device ------------------------------------------------------------------ Anurag Kapur Associate - Technology, Sapient Corporation. +44 (0) 7514 996 586 http://www.linkedin.com/in/anuragkapur http://www.google.com/profiles/anuragkapur ------------------------------------------------------------------ --------------------------------------------------------------------- The official User-To-User support forum of the Apache HTTP Server Project. See <URL:http://httpd.apache.org/userslist.html> for more info. To unsubscribe, e-mail: users-unsubscribe@xxxxxxxxxxxxxxxx " from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx