Return-Path: X-Original-To: apmail-httpd-users-archive@www.apache.org Delivered-To: apmail-httpd-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 26D8A3B53 for ; Mon, 2 May 2011 04:47:32 +0000 (UTC) Received: (qmail 18981 invoked by uid 500); 2 May 2011 04:47:28 -0000 Delivered-To: apmail-httpd-users-archive@httpd.apache.org Received: (qmail 18959 invoked by uid 500); 2 May 2011 04:47:28 -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 18911 invoked by uid 99); 2 May 2011 04:47:26 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 02 May 2011 04:47:26 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [203.63.38.2] (HELO alpha.arc.net.au) (203.63.38.2) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 02 May 2011 04:47:16 +0000 Received: from [192.168.1.60] (barra [203.63.39.229]) by alpha.arc.net.au (8.12.11/8.12.10) with ESMTP id p424koOo029522 for ; Mon, 2 May 2011 14:46:51 +1000 (envelope-from spliff@warriorhut.org) Message-ID: <4DBE373B.1080705@warriorhut.org> Date: Mon, 02 May 2011 14:46:51 +1000 From: SpliFF User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110501 Lightning/1.0b3pre Thunderbird/3.1.10 MIME-Version: 1.0 To: users@httpd.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-PMX-Version: 4.7.1.128075, Antispam-Engine: 2.5.2.313940, Antispam-Data: 2009.3.17.90106 X-PerlMx-Spam: Gauge=IIIIIII, Probability=7%, Report='FROM_NAME_ONE_WORD 0.05, BODY_SIZE_3000_3999 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, __CP_MEDIA_BODY 0, __CT 0, __CTE 0, __CT_TEXT_PLAIN 0, __HAS_MSGID 0, __MIME_TEXT_ONLY 0, __MIME_VERSION 0, __SANE_MSGID 0, __STOCK_PHRASE_7 0, __USER_AGENT 0' X-Virus-Checked: Checked by ClamAV on apache.org Subject: [users@httpd] Need help with tricky mod_cache configuration I'm trying to configure mod_cache in Apache 2.2.17 to act as a transparent cache for an application server but I have some special requirements whose overall purpose is to cache "public" access but bypass the cache when users are logged in. I'm setting a cookie "NOCACHE=on" when the user logs in and checking for that cookie in Apache. For this to work clients must always revalidate with the cache (to send the cookies). My requirements are: * Clients should always revalidate with the cache but NOT the application server unless a special cookie is set. * If a page is in the Apache cache the cache should send 304, not the whole page. * If user shift-refreshes the browser always revalidate with the application server. * I can't use alternate domains, ssl or special paths or query strings for logged-in users because my application isn't designed that way. I'm been experimenting with different headers and cache options but so far I haven't found a solution that satisfies all the requirements. Generally when I get one thing to work another breaks eg: * The HTTP spec solution of using vary: Set-Cookie won't work because the application sets session cookies and you can't pick one cookie out of the string. * Using 'CacheIgnoreCacheControl on' allows the cache to work with no-cache headers but prevents shift-refresh from hitting the application server. * Setting max-age=0 or no-cache in headers with 'CacheIgnoreCacheControl off' causes the page to not cache in Apache at all. * Setting no-store with 'CacheStoreNoStore On' is pretty close but since the client wont store the page the cache is sending the whole response body every time (not 304). My vhost config: ==================== # Expiry and cache-control # Set expires header ExpiresActive On ExpiresDefault "access plus 1 days" #ExpiresByType text/html "now" # Check for NOCACHE cookie sent by logged-in users and bypass the cache SetEnvIf Cookie "NOCACHE" no-cache Header set Cache-Control "no-cache" env=no-cache # Force all requests to re-validate so cookies are sent even when the browser has cached the page Header append Cache-Control "must-revalidate" # Don't cache cookie headers CacheIgnoreHeaders Set-Cookie # Enable disk cache CacheEnable disk / CacheDisable /images CacheDisable /styles CacheDisable /scripts CacheDisable /base CacheDisable /users CacheDisable /admin CacheRoot /var/cache/apache2 # Various attempts to treat this cache differently to downstream caches #CacheStoreNoStore On #CacheIgnoreCacheControl on #CacheIgnoreNoLastMod On # Forward uncached requests to the application server RewriteEngine On RewriteCond %{REQUEST_FILENAME} !/[^/:]+\.[^/:]{2,5}$ RewriteRule (.*) /index.cfm$1 [PT,L] ==================== Final thing, the Apache docs seem to use CacheStoreNo*Store* and CacheStoreNo*Cache* interchangeably. Is this an alias or a typo? Which is correct? --------------------------------------------------------------------- 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