Erica, My only comments: either (1) the request parameters are killing mod_cache's desire to cache the file or (2) something is different in the headers between your JavaScript and PHP responses.
I would: (1) Try requesting /gethint.php without any GET/POST parameters (your app should respond with correctly formatted XML [probably returning an error code]). Is this file cached (with/without the force-caching directive)? (2) Compare the javascript and xml response headers and compare any differences. I would think forcing mod_cache to ignore all headers would make this trivial... but this may reveal something which may be missing. (3) Clear your cache directory and see if your XML response creates a file, then check if your javascript file creates a cache file (assuming you are still using mod_file_cache) Regards, Dave On 3/6/07, Erica Zhang <[EMAIL PROTECTED]> wrote:
Yes. I changed the PHP script. Now I change them back and also set CacheIgnoreCacheControl On. And still could not work. For other questions, please see the my answers below. Thanks. David Wortham wrote: > Erica, > My observations of your headers: > (1) The "Last-Modified" line contains the current timestamp (as expected) After I set CacheIgnoreCacheControl On, it does not matter. Right ? Although I move the headers to the top code, it still could not work. > (2) Your original question showed that you inserted an "Expires:" header, > but it doesn't show in your response. Did you change your PHP script > code > since you asked the original question this morning? Yes. It is my fault. > (3) Are you returning XML or HTML? My experience with XMLHttpResponse(s) > required changing the content-type to "text/xml" (not really the issue at > hand) > Does it matter ? > When you said that you got mod_cache to cache a JavaScript file, was > it in > the same directory (and covered by the same mod_cache directives)? Yes, both javascript file and the php file are under htdocs directory. > > Did you try using the > CacheIgnoreCacheControl On > directive? Did it force the file to cache? I tried. But it could not work. > > Regards, > Dave > > > On 3/6/07, Erica Zhang <[EMAIL PROTECTED]> wrote: > >> >> I use live http headers to catch the headers. I listed them below. Well >> I found that php file has not been given the http headers. So is this >> the problem for not caching the response produced by it ? Then how can I >> handle this problem ? Also, is there some mod_cache log that I could >> refer ? Thanks. >> >> http://128.189.246.64/gethint.php?q=Eric&sid=0.11837499670287688 >> >> GET /gethint.php?q=Eric&sid=0.11837499670287688 HTTP/1.1 >> Host: 128.189.246.64 >> User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.2) >> Gecko/20070219 Firefox/2.0.0.2 >> Accept: >> text/xml,application/xml,application/xhtml+xml,text/html;q=0.9 >> ,text/plain;q=0.8,image/png,*/*;q=0.5 >> Accept-Language: en-us,en;q=0.5 >> Accept-Encoding: gzip,deflate >> Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 >> Keep-Alive: 300 >> Connection: keep-alive >> Referer: http://128.189.246.64/ >> >> HTTP/1.x 200 OK >> Date: Tue, 06 Mar 2007 22:35:34 GMT >> Server: Apache/2.0.59 (Win32) >> X-Powered-By: PHP/4.4.4 >> Cache-Control: public >> Last-Modified: Tue, 06 Mar 2007 22:35:34 GMT >> Keep-Alive: timeout=15, max=10000 >> Connection: Keep-Alive >> Transfer-Encoding: chunked >> Content-Type: text/html >> >> >> Erica Zhang wrote: >> >> > Well, even I use the blinding-cache. It still could not work. Thanks, >> > >> > Erica >> > >> > David Wortham wrote: >> > >> >> Erica, >> >> I'm not sure why mod_cache should not be able to work (assuming >> your >> >> module and pages are configured correctly). >> >> >> >> IIRC, JavaScript is used on the presentation request (with the >> >> webpage), >> >> whereas the XMLHttpRequest response is a PHP-generated XML document. >> >> Perhaps your extension ('.php" maybe?) or the mime/content-type >> >> ("text/xml") >> >> is what is causing mod_cache to skip the file? >> >> >> >> Also, from what I can gather, using mod_cache with mod_proxy (as a >> >> caching proxy) can alter the effects of mod_cache slightly. You may >> >> want to >> >> read up on that. >> >> >> >> Try using the following directive with mod_cache: >> >> CacheIgnoreNoLastMod On >> >> >> >> see: >> >> >> http://webauth.stanford.edu/manual/mod/mod_cache.html#CacheIgnoreNoLastMod >> >> >> >> >> >> >> This apparently forces blind-caching which Joe suggests is bad (I >> >> don't know >> >> anything about it). Short of that, you just need to read the >> mod_cache >> >> manual and make sure your XML response contains the necessary headers >> >> to get >> >> mod_cache to work correctly. >> >> >> >> Regards, >> >> Dave >> >> >> >> >> >> >> >> On 3/6/07, Erica Zhang <[EMAIL PROTECTED]> wrote: >> >> >> >>> >> >>> No, still not work. Infact, mod_cache could work, because it could >> >>> cache >> >>> the javascript. But it could not work for dynamic HTTP responses >> >>> responding to XMLHttpRequests in Ajax technology. So I suspect >> >>> mod_cache >> >>> could not support this function. And I need provide such function by >> >>> myself. I prefer to do it in Apache, a comparatively general way >> >>> instead >> >>> of application itself. >> >>> >> >>> >> >>> Erica >> >>> >> >>> Joachim Zobel wrote: >> >>> >> >>> >Am Montag, den 05.03.2007, 22:53 -0800 schrieb Erica Zhang: >> >>> > >> >>> > >> >>> >>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 am not shure about mod_caches behaviour, but omitting >> >>> last-modified is >> >>> >worth a try. >> >>> > >> >>> >Sincerely, >> >>> >Joachim >> >>> > >> >>> > >> >>> > >> >>> >> >>> >> >> >> >> >
