You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Phil Endecott <sp...@chezphil.org> on 2004/11/15 20:31:02 UTC

[users@httpd] mod_disk_cache difficulties

Dear Apache Experts,

I am hoping to be able to use mod_cache and mod_disk_cache to cache the 
output from a slow CGI process and thereby reduce server load and 
increase responsiveness.  The CGI process decodes and generates the 
necessary HTTP headers so that browser caching of this content works. 
So far, however, I have not managed to get Apache to cache this content. 
  Providing a server-side shared cache would give me a significant 
performance boost and I would love to get it working.

I have this in my configuration file:

     CacheRoot "/var/cache/apache2/proxy"
     CacheDefaultExpire 600000
     CacheEnable disk /
     CacheForceCompletion 10
     CacheIgnoreNoLastMod On
     CacheSize 500000

Looking at localhost/server-info I can see that the modules are loaded 
and have been initialised with these configuration settings.  Looking at 
the content of the cache directory I can see that static content is 
being cached (though I plan to disable this).

My CGI program typically sends responses to GET requsts with headers 
like the following:

Vary: Cookie
Cache-Control: must-revalidate
ETag: "ghetuierhgreiu"

When these go directly to the browser, subsequent requests for the same 
URI send an If-None-Match header with the old Etag, and the CGI process 
returns a 304 response unless a change to the database or to the user's 
cookies indicate that the result is now different (and a different ETag 
is required).  This works.

My fear is that when Apache sees the headers that I am generating it 
decides that this content is uncacheable (because of must-revalidate or 
etags).  Could this be true?  Have other users got something like this 
to work?  Are there any debug techniques that I should know about?  Can 
I get any useful trace information from any of these modules?  Can some 
useful header be inserted in the response to indicate if or why it was 
or wasn't cached?

This is with the Debian version of 2.0.52.

Below are some header traces from Mozilla showing an initial fetch 
followed by a second fetch that returns a 304.

Many thanks for any suggestions help than anyone can offer.

Regards,

Phil.




1084485888[809d868]: http request [
1084485888[809d868]:   GET /treefic/work/treefic/test?a=tree_page HTTP/1.1
1084485888[809d868]:   Host: andorra
1084485888[809d868]:   User-Agent: Mozilla/5.0 (X11; U; Linux i686; 
en-US; rv:1.7) Gecko/20040719 Firefox/0.9.1
1084485888[809d868]:   Accept: 
text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
1084485888[809d868]:   Accept-Language: en-us,en;q=0.5
1084485888[809d868]:   Accept-Encoding: gzip,deflate
1084485888[809d868]:   Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
1084485888[809d868]:   Keep-Alive: 300
1084485888[809d868]:   Connection: keep-alive
1084485888[809d868]:   Referer: 
http://andorra/treefic/work/treefic/test?a=news_page
1084485888[809d868]:   Cookie: treefic_test_SessionID="67202642"
1084485888[809d868]: ]
1103780784[812bb98]: http response [
1103780784[812bb98]:   HTTP/1.1 200 OK
1103780784[812bb98]:   Date: Mon, 15 Nov 2004 19:21:10 GMT
1103780784[812bb98]:   Server: Apache/2.0.52 (Debian GNU/Linux)
1103780784[812bb98]:   Vary: Cookie
1103780784[812bb98]:   Etag: "b35ffcdaefc52a67d5b3fb2217a2d0b51e8147d9"
1103780784[812bb98]:   Cache-Control: must-revalidate
1103780784[812bb98]:   Keep-Alive: timeout=15, max=100
1103780784[812bb98]:   Connection: Keep-Alive
1103780784[812bb98]:   Transfer-Encoding: chunked
1103780784[812bb98]:   Content-Type: text/html
1103780784[812bb98]: ]


1084485888[809d868]: http request [
1084485888[809d868]:   GET /treefic/work/treefic/test?a=tree_page HTTP/1.1
1084485888[809d868]:   Host: andorra
1084485888[809d868]:   User-Agent: Mozilla/5.0 (X11; U; Linux i686; 
en-US; rv:1.7) Gecko/20040719 Firefox/0.9.1
1084485888[809d868]:   Accept: 
text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
1084485888[809d868]:   Accept-Language: en-us,en;q=0.5
1084485888[809d868]:   Accept-Encoding: gzip,deflate
1084485888[809d868]:   Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
1084485888[809d868]:   Keep-Alive: 300
1084485888[809d868]:   Connection: keep-alive
1084485888[809d868]:   Referer: 
http://andorra/treefic/work/treefic/test?a=news_page
1084485888[809d868]:   Cookie: treefic_test_SessionID="67202642"
1084485888[809d868]:   If-None-Match: 
"b35ffcdaefc52a67d5b3fb2217a2d0b51e8147d9"
1084485888[809d868]:   Cache-Control: max-age=0
1084485888[809d868]: ]
1103780784[812bb98]: http response [
1103780784[812bb98]:   HTTP/1.1 304 Not Modified
1103780784[812bb98]:   Date: Mon, 15 Nov 2004 19:21:56 GMT
1103780784[812bb98]:   Server: Apache/2.0.52 (Debian GNU/Linux)
1103780784[812bb98]:   Connection: Keep-Alive
1103780784[812bb98]:   Keep-Alive: timeout=15, max=100
1103780784[812bb98]:   Etag: "b35ffcdaefc52a67d5b3fb2217a2d0b51e8147d9"
1103780784[812bb98]: ]


---------------------------------------------------------------------
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_disk_cache difficulties

Posted by Ralf Glauberman <rg...@michaeli-gymnasium.de>.
well,
you could simply remove the
Vary: Cookie
Cache-Control: must-revalidate
but this depends very much on your needs. what is the cgi used for?

>I asked:
>>>> I am hoping to be able to use mod_cache and mod_disk_cache to cache the
>>>> output from a slow CGI process and thereby reduce server load and
>>>> increase responsiveness.  The CGI process decodes and generates the
>>>> necessary HTTP headers so that browser caching of this content works.
>>>> So far, however, I have not managed to get Apache to cache this 
>>>> content.
>>>> Providing a server-side shared cache would give me a significant
>>>> performance boost and I would love to get it working.
> >>>
>>>> Vary: Cookie
>>>> Cache-Control: must-revalidate
>>>> ETag: "ghetuierhgreiu"
>
> Joshua replied:
>>> I know very little about mod_cache, but it is my understanding that it
>>> has no support for Vary, and will therefore mark all headers with Vary
>>> in them as uncachable.
>
> Ralf wrote:
> > well, one idea would be to put another cgi-wrapper around the original
> > cgi modifying the headers. not very clean but might work.
>
> Hi Ralf,
>
> What modification to the headers do you suggest?
>
> Regards,
>
> Phil.
>
>
> ---------------------------------------------------------------------
> 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_disk_cache difficulties

Posted by Phil Endecott <sp...@chezphil.org>.
I asked:
>>> I am hoping to be able to use mod_cache and mod_disk_cache to cache the
>>> output from a slow CGI process and thereby reduce server load and
>>> increase responsiveness.  The CGI process decodes and generates the
>>> necessary HTTP headers so that browser caching of this content works.
>>> So far, however, I have not managed to get Apache to cache this content.
>>> Providing a server-side shared cache would give me a significant
>>> performance boost and I would love to get it working.
 >>>
>>> Vary: Cookie
>>> Cache-Control: must-revalidate
>>> ETag: "ghetuierhgreiu"

Joshua replied:
>> I know very little about mod_cache, but it is my understanding that it
>> has no support for Vary, and will therefore mark all headers with Vary
>> in them as uncachable.

Ralf wrote:
 > well, one idea would be to put another cgi-wrapper around the original
 > cgi modifying the headers. not very clean but might work.

Hi Ralf,

What modification to the headers do you suggest?

Regards,

Phil.


---------------------------------------------------------------------
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_disk_cache difficulties

Posted by Ralf Glauberman <rg...@michaeli-gymnasium.de>.
well, one idea would be to put another cgi-wrapper around the original cgi 
modifying the headers. not very clean but might work.
ralf

----- Original Message ----- 
From: "Joshua Slive" <js...@gmail.com>
To: <us...@httpd.apache.org>
Sent: Tuesday, November 16, 2004 5:15 PM
Subject: Re: [users@httpd] mod_disk_cache difficulties


> On Mon, 15 Nov 2004 19:31:02 +0000, Phil Endecott
> <sp...@chezphil.org> wrote:
>> I am hoping to be able to use mod_cache and mod_disk_cache to cache the
>> output from a slow CGI process and thereby reduce server load and
>> increase responsiveness.  The CGI process decodes and generates the
>> necessary HTTP headers so that browser caching of this content works.
>> So far, however, I have not managed to get Apache to cache this content.
>>   Providing a server-side shared cache would give me a significant
>> performance boost and I would love to get it working.
>
>> Vary: Cookie
>> Cache-Control: must-revalidate
>> ETag: "ghetuierhgreiu"
>
> I know very little about mod_cache, but it is my understanding that it
> has no support for Vary, and will therefore mark all headers with Vary
> in them as uncachable.
>
> Joshua.
>
> ---------------------------------------------------------------------
> 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_disk_cache difficulties

Posted by Joshua Slive <js...@gmail.com>.
On Mon, 15 Nov 2004 19:31:02 +0000, Phil Endecott
<sp...@chezphil.org> wrote:
> I am hoping to be able to use mod_cache and mod_disk_cache to cache the
> output from a slow CGI process and thereby reduce server load and
> increase responsiveness.  The CGI process decodes and generates the
> necessary HTTP headers so that browser caching of this content works.
> So far, however, I have not managed to get Apache to cache this content.
>   Providing a server-side shared cache would give me a significant
> performance boost and I would love to get it working.

> Vary: Cookie
> Cache-Control: must-revalidate
> ETag: "ghetuierhgreiu"

I know very little about mod_cache, but it is my understanding that it
has no support for Vary, and will therefore mark all headers with Vary
in them as uncachable.

Joshua.

---------------------------------------------------------------------
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