homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Apache Web Server
Forum Library, Charter, Moderators: Ocean10000 & incrediBILL & phranque

Apache Web Server Forum

Can't get Apache mod cache working
creating caches but not reading from them

10+ Year Member

Msg#: 3516035 posted 11:06 am on Nov 29, 2007 (gmt 0)

I'm trying to set up apache mod_cache to cache dynamic pages (generated by PHP) so as to accelerate this server. Now Apache can create lots of cache files in the specified folder. The problem is that apache doesn't read from these caches to feed requests.

1. My server environment is REDHAT Enterprise 3 i686 on standard - WHM X v3.1.0 + Apache 2.2.6 + PHP 5.2.5 .
2. I've installed modules including mod_cache, mod_disk_cache, mod_mem_cache and mod_expires.
mod_cache related settings£º
CacheRoot /home/apachecache
CacheEnable disk /
CacheDirLevels 2
CacheDirLength 1
CacheDefaultExpire 86400
CacheMaxExpire 86400

3. I add the following lines in the test php page to make apache cache the result:
header("Expires: " . gmdate('D, d M Y H:i:s', time()+3600*72) ." MT" );
header("Last-Modified: ".gmdate('D, d M Y H:i:s') . ' GMT');
header("Cache-Control: public,max-age=604800");

4. I also add the following lines to the test page so that I can tell whether it is read from cache:
echo date("H:i:s");

After the above settings, I can see cache files are created but the page itself is always 'fresh' . Anybody here can help me? Thanks!



10+ Year Member

Msg#: 3516035 posted 6:16 pm on Dec 5, 2007 (gmt 0)

Caching behavior is also affected by the client (browser), so first I'd make sure it is not the case, by either changing the caching parameters of the browser, or by checking the Apache with a software which shows the http headers (of the request and the response too). Second, the php has some influence on this, if the sessions are enabled (started) it sets numerous cache restricting headers.


10+ Year Member

Msg#: 3516035 posted 12:36 am on Dec 6, 2007 (gmt 0)

Thanks gergoe! I found it was highly related with the browser's header. It is not a big problem since the reason is found and now everything is ok now.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Apache Web Server
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved