David,

Thanks a lot for your reply. While, I just want to cache HTTP responses produced by PHP scripts. Of course, those responses perhaps include PHP scripts. On the other hand, I know I could do it by use of PHP itself. I just want to provide a general one. This means no matter what kind of script or languages used for server development, for example, ASP, PHP, Java and etc, I could use only one module to cache those HTTP responses. I thought Apache could handle or filter HTTP responses or requests. So I want to add modules to handle caching dynamic HTTP responses problems.

However, based on your suggestion, it seems that I have to developed separate ones for Java, ASP, PHP. Right ? But is there some general way to cache responses ?

Thanks,

Erica

David Wortham wrote:

Erica,
IMO, your caching should take place on the PHP side of things, not Apache
or any Apache modules (save for maybe mod_php).

Depending on how frequently the cache should refresh, I would either have (1) PHP write the newest response to a file and check the timestamp of the
file to check if  the cachefile should be updated,
(2) Don't use PHP called from a webserver, but rather use PHP called from a
cron job, or
(3) find out how to use PHP to cache itself (I'm pretty sure Apache won't
cache PHP, ASP, etc.)

For help on any three of these things, I would recommend asking at a
PHP-specific forum/mailing list or on www.php.net (the comments on that site
are sometimes extremely helpful).

Regards,
David Wortham




On 3/5/07, Erica Zhang <[EMAIL PROTECTED]> wrote:


Hi,

I want to develop a filter module to cache responses for XMLHttp
requests for Apache. Before that, I have tried to configure using
mod_cache. I found that it could not be used to cache responses for
XMLHttp requests. However, I am not sure about this, because I am new to
web applications. So before beginning to develop a new module to do this
function, I want to make sure that. Is there some expert tell me about
your idea on this topic or experiences ?

I tried to give more details below:

For mod_cache, I use httpd.conf to configure it:

MaxKeepAliveRequests 10000
<IfModule mpm_winnt.c>
    ThreadsPerChild 1900
    MaxRequestsPerChild 10000
</IfModule>

LoadModule cache_module modules/mod_cache.so

<IfModule mod_cache.c>
    CacheForceCompletion 100
    CacheDefaultEXPire 3600
    CacheMaxExpire 86400
    CacheLastModifiedFactor 0.1
    LoadModule disk_cache_module modules/mod_disk_cache.so

    <IfModule mod_disk_cache.c>
        CacheEnable disk /
        CacheRoot c:/cacheroot
        CacheSize 327680
        CacheDirLength 4
        CacheDirLevels 5
        CacheGcInterval 4
    </IfModule>

    #LoadModule mem_cache_module modules/mod_mem_cache.so
    <IfModule mod_mem_cache.c>
        CacheEnable mem /
        MCacheSize 8192
        MCacheMaxObjectCount 10000
        MCacheMinObjectSize 1
        MCacheMaxObjectSize 51200
    </IfModule>
</IfModule>

On client, I use ajax technology and XMLHttpRequest  and on server, I
use php script.
...
header("Cache-Control: public"); // HTTP/1.1
header("Expires: " .gmdate ("D, d M Y H:i:s", time() + 60 * 10). " GMT");
header( "Last-Modified: " .gmdate( 'D, d M Y H:i:s' ). " GMT" );
echo $response;
....
I think apache cache should catch my response produced by PHP. Until
now, I do not think there is something wrong in my code or
configuration. So I conclude that mod_cache could not catch the
responses for XMLHttp requests.

Regards,

Erica





Reply via email to