Return-Path: Delivered-To: apmail-httpd-users-archive@www.apache.org Received: (qmail 77486 invoked from network); 15 Mar 2010 13:31:01 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 15 Mar 2010 13:31:01 -0000 Received: (qmail 76681 invoked by uid 500); 15 Mar 2010 13:30:12 -0000 Delivered-To: apmail-httpd-users-archive@httpd.apache.org Received: (qmail 76631 invoked by uid 500); 15 Mar 2010 13:30:12 -0000 Mailing-List: contact users-help@httpd.apache.org; run by ezmlm Precedence: bulk Reply-To: users@httpd.apache.org list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list users@httpd.apache.org Received: (qmail 76623 invoked by uid 99); 15 Mar 2010 13:30:12 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 15 Mar 2010 13:30:12 +0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of anuragkapur@gmail.com designates 209.85.218.215 as permitted sender) Received: from [209.85.218.215] (HELO mail-bw0-f215.google.com) (209.85.218.215) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 15 Mar 2010 13:30:06 +0000 Received: by bwz7 with SMTP id 7so2802633bwz.24 for ; Mon, 15 Mar 2010 06:29:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type; bh=VMbbjuiBX3yA7/hkoIU6XMPjtU+OSKZfZDPlwXOvfWo=; b=C2WFV75ecUfFO6f1HEPy2Va4MEKIWhqu7ZeJVcux5m9kh4DzSfxOg02Q/nJ6VVGYK0 EJfVesGngvtzal9DiVmDlHEnIW72aP3JWcrQtur3TdK0gDhTqmJpxTyExVhs4vbEo8u8 FwVvP4i+o14Asnzwpp19N2hx0yUy7o9GOarwQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=hJcuNpxDEBWeo0RmskM3Z8JELcrljqUJ1wQNDVwxaEl88cemREpiwjUbd3aDY/xrL0 7x3O38kxcJRFiEMKZBepy1ghbcS/IuUNYAjrkJWeecyUNGOYd0Z2njM6nmb2LQx0vomN rHtC9lye679CKcTOsDJZZLQF5KqU1ZzEn/+kE= MIME-Version: 1.0 Received: by 10.204.137.16 with SMTP id u16mr7139995bkt.165.1268659786432; Mon, 15 Mar 2010 06:29:46 -0700 (PDT) In-Reply-To: <1a20111c1003150615q40c08a96vb66659c4fa80818f@mail.gmail.com> References: <2fb267f81003150550q7e34c386wbbfcae2f00151e04@mail.gmail.com> <1a20111c1003150615q40c08a96vb66659c4fa80818f@mail.gmail.com> Date: Mon, 15 Mar 2010 13:29:46 +0000 Message-ID: <2fb267f81003150629o3158304dld3977e7908a54c79@mail.gmail.com> From: Anurag Kapur To: users@httpd.apache.org Content-Type: text/plain; charset=ISO-8859-1 X-Virus-Checked: Checked by ClamAV on apache.org Subject: [users@httpd] Re: Conditionally Setting HTTP Response Header 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 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 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 for more info. To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org " from the digest: users-digest-unsubscribe@httpd.apache.org For additional commands, e-mail: users-help@httpd.apache.org