Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Apache2 mod_cache Help

Status
Not open for further replies.

shawntendo

Programmer
Mar 15, 2005
2
US
I am currently looking for a way to cache files to disk using the experimental mod_cache module with Apache2. I want to cache javascript files from a specified directory every thirty seconds. Here is what I have in my .conf file right now:

#
# Mod Cache Config
#
LoadModule cache_module modules/mod_cache.so
LoadModule disk_cache_module/mod_disk_cache.so

<IfModule mod_cache.c>
CacheDefaultExpire 120
CacheMaxExpire 120
<IfModule mod_disk_cache.c>
CacheRoot C:\cacheroot
CacheSize 99999
CacheDirLevels 2
CacheDirLength 3
CacheEnable disk /runtime/javascriptcache/national
</IfModule>
</IfModule>

#
#End of Moudle
#


The behavior I am getting from this function is extremely confusing. I will see if I can explain it step by step.

-Lets say I had a file called testfile.js in my /runtime/javascriptcache/national/ directory. When I call this file for the first time through the URL a 3 letter directory is created in my C:\cacheroot directory. Inside this is another 3 letter directory (because of CacheDirLevel 2). And inside of that is the .header and .data cached files. Looks good so far...

Now lets say I were to immediately delete the testfile.js file after it was cached and I would try to call it again. For 30 seconds Apache will still bring up the cached version of this file. Once the 30 seconds pass I will get a "file not found" in my browser. Still lookin pretty good.

Now here comes the confusing part. Say I put back the testfile.js in my runtime/javascriptcache/national directory and delete all of the cached directories and files inside of my C:\cacheroot directory. Then I go and try to call the file through the URL again. I'd expect Apache to recognize that this file has not been cached yet so it would create new cache files for it ... but it does not! Even if Apache is restarted, it will never again create a new record in the cache of this file.

Also, say I left the cache files alone but I modified my testfile.js file a day from now. This would be well over the 30 second cacheExpire that I set. I'd expect Apache to recognize that the cache file and the new file do not match so it would make a new record in the cache of this different file -- it does not. I'm really just confused at what the advantage of caching a page only one time really is worth. Maybe there is something else that can do what I need?

I understand this is an experimental module still but if anyone could help me out with this problem it would be much appreciated. Thanks in advance.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top