You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Brendon Anderson <br...@gmail.com> on 2011/10/05 15:16:07 UTC

[users@httpd] mod_cache is caching content with Cache-Control: private response headers

I am setting the Cache-Control: private header in a response on a
certain url, but mod_cache is still caching this url.

Response Headers as indicated by Firefox (Chrome reports similar results):

Response Headers
Date	Wed, 05 Oct 2011 12:58:41 GMT
Server	Apache/2.2.20 (Win32) mod_jk/1.2.32
Expires	Wed, 05 Oct 2011 12:59:25 GMT
Cache-Control	private
Content-Language	en-US
Content-Length	7046
Age	15
Content-Type	text/html;charset=UTF-8
X-Cache	MISS from x.y.z.com
Via	1.0 x.y.z.com:80 (squid/2.6.STABLE22)
Proxy-Connection	keep-alive

Logs indicating url is being cached (url set to private is /hrportal/home):

(accessing using Chrome)
[Wed Oct 05 07:58:25 2011] [debug] mod_cache.c(757): cache: Removing
CACHE_REMOVE_URL filter.
[Wed Oct 05 07:58:25 2011] [info] mem_cache: Cached url:
http://blahfoobar:8080/hrportal/home?
(accessing using Firefox)
[Wed Oct 05 07:58:41 2011] [debug] mod_cache.c(298): cache: running
CACHE_OUT filter
[Wed Oct 05 07:58:41 2011] [debug] mod_cache.c(312): cache: serving
/hrportal/home

Mod_cache config:
<IfModule mod_cache.c>
	CacheIgnoreNoLastMod On
	CacheIgnoreQueryString On
	CacheIgnoreHeaders Set-Cookie
	CacheIgnoreURLSessionIdentifiers jsessionid

	CacheStorePrivate Off

	<IfModule mod_mem_cache.c>
		CacheEnable mem /
		#100MB in KB
		MCacheSize 102400
		#MCacheMinObjectSize 1
		#4MB in bytes
		MCacheMaxObjectSize 4194304
	</IfModule>
</IfModule>

What am I doing wrong?  From my reading on mod_cache, it should NOT
cache if the Cache-Control header contains private.

---------------------------------------------------------------------
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@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] mod_cache is caching content with Cache-Control: private response headers

Posted by Brendon Anderson <br...@gmail.com>.
I think I have this figured out, but am interested to know if this is
a bug or expected behavior.

So I had Spring add a Cache-Control: max-age=600 header in the
configuration.  I was also adding a Cache-Control: private header in
the Java code in a specific place, more or less for testing.  I could
see both headers come through on Firefox and Chrome, but mod_cache
refused to obey the private header and would cache that request.  I
took out the automatic spring stuff and just added the private header
in my code.  My gosh, it worked!  Mod_cache would NOT cache that
specific request, exactly what I wanted.

My thought is that two Cache-Control headers were coming through and
mod_cache obeyed one or the other, not both (and it happened to not
obey the private one probably because of the order).

Does this sound feasible?  Bug?

On Wed, Oct 5, 2011 at 9:00 AM, Brendon Anderson <br...@gmail.com> wrote:
> I am 100% sure.  I am adding the header using Java code on Tomcat
> behind Apache.  If I remove that particular line from the code, the
> Cache-Control: private header is not being sent.
>
> Java code, if it matters:
> response.addHeader("Cache-Control", "private");
>
> On Wed, Oct 5, 2011 at 8:53 AM, Tom Evans <te...@googlemail.com> wrote:
>> On Wed, Oct 5, 2011 at 2:16 PM, Brendon Anderson <br...@gmail.com> wrote:
>>> I am setting the Cache-Control: private header in a response on a
>>> certain url, but mod_cache is still caching this url.
>>>
>>> Response Headers as indicated by Firefox (Chrome reports similar results):
>>>
>>> Response Headers
>>> Date    Wed, 05 Oct 2011 12:58:41 GMT
>>> Server  Apache/2.2.20 (Win32) mod_jk/1.2.32
>>> Expires Wed, 05 Oct 2011 12:59:25 GMT
>>> Cache-Control   private
>>> Content-Language        en-US
>>> Content-Length  7046
>>> Age     15
>>> Content-Type    text/html;charset=UTF-8
>>> X-Cache MISS from x.y.z.com
>>> Via     1.0 x.y.z.com:80 (squid/2.6.STABLE22)
>>> Proxy-Connection        keep-alive
>>>
>>
>> Are you 100% sure that the Cache-Control header is being sent with the
>> content, and it is not being added by the Squid cache that you are
>> also going through?
>>
>> Cheers
>>
>> Tom
>>
>> ---------------------------------------------------------------------
>> 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@httpd.apache.org
>>   "   from the digest: users-digest-unsubscribe@httpd.apache.org
>> For additional commands, e-mail: users-help@httpd.apache.org
>>
>>
>

---------------------------------------------------------------------
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@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] mod_cache is caching content with Cache-Control: private response headers

Posted by Brendon Anderson <br...@gmail.com>.
I am 100% sure.  I am adding the header using Java code on Tomcat
behind Apache.  If I remove that particular line from the code, the
Cache-Control: private header is not being sent.

Java code, if it matters:
response.addHeader("Cache-Control", "private");

On Wed, Oct 5, 2011 at 8:53 AM, Tom Evans <te...@googlemail.com> wrote:
> On Wed, Oct 5, 2011 at 2:16 PM, Brendon Anderson <br...@gmail.com> wrote:
>> I am setting the Cache-Control: private header in a response on a
>> certain url, but mod_cache is still caching this url.
>>
>> Response Headers as indicated by Firefox (Chrome reports similar results):
>>
>> Response Headers
>> Date    Wed, 05 Oct 2011 12:58:41 GMT
>> Server  Apache/2.2.20 (Win32) mod_jk/1.2.32
>> Expires Wed, 05 Oct 2011 12:59:25 GMT
>> Cache-Control   private
>> Content-Language        en-US
>> Content-Length  7046
>> Age     15
>> Content-Type    text/html;charset=UTF-8
>> X-Cache MISS from x.y.z.com
>> Via     1.0 x.y.z.com:80 (squid/2.6.STABLE22)
>> Proxy-Connection        keep-alive
>>
>
> Are you 100% sure that the Cache-Control header is being sent with the
> content, and it is not being added by the Squid cache that you are
> also going through?
>
> Cheers
>
> Tom
>
> ---------------------------------------------------------------------
> 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@httpd.apache.org
>   "   from the digest: users-digest-unsubscribe@httpd.apache.org
> For additional commands, e-mail: users-help@httpd.apache.org
>
>

---------------------------------------------------------------------
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@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] mod_cache is caching content with Cache-Control: private response headers

Posted by Tom Evans <te...@googlemail.com>.
On Wed, Oct 5, 2011 at 2:16 PM, Brendon Anderson <br...@gmail.com> wrote:
> I am setting the Cache-Control: private header in a response on a
> certain url, but mod_cache is still caching this url.
>
> Response Headers as indicated by Firefox (Chrome reports similar results):
>
> Response Headers
> Date    Wed, 05 Oct 2011 12:58:41 GMT
> Server  Apache/2.2.20 (Win32) mod_jk/1.2.32
> Expires Wed, 05 Oct 2011 12:59:25 GMT
> Cache-Control   private
> Content-Language        en-US
> Content-Length  7046
> Age     15
> Content-Type    text/html;charset=UTF-8
> X-Cache MISS from x.y.z.com
> Via     1.0 x.y.z.com:80 (squid/2.6.STABLE22)
> Proxy-Connection        keep-alive
>

Are you 100% sure that the Cache-Control header is being sent with the
content, and it is not being added by the Squid cache that you are
also going through?

Cheers

Tom

---------------------------------------------------------------------
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@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org