简体   繁体   中英

Using mod_disk_cache in Apache?

I want to use mod_disk_cache in apache to cache my xml feeds to a folder and serve direct from that folder. These are feeds dynamically created by php - but not changing very often. I want the caching at the htaccess level to avoid any strain/call to php and keep server stress to a minimum.

http://httpd.apache.org/docs/2.2/mod/mod_cache.html

httpd.apache.org/docs/2.2/mod/mod_disk_cache.html

Has anyone done this before? Did it work for you? I'm getting my server company to install the modules I need and can then have a go myself.

I'm hoping to use something similar to:

    <IfModule mod_cache.c>
      <IfModule mod_disk_cache.c>
         CacheRoot c:/cacheroot
         CacheEnable disk /
         CacheDirLevels 5
         CacheDirLength 3
     </IfModule>    
   </IfModule> 

I'll be sending Expires: and Last-Modified: headers in the xml too.

Think this will give me the desired solution and filling that cache folder and avoiding calls to php? Or is this approach all wrong? Thanks in advance for any guidance

I used in the past Apache with mod_cache on a Unix environment. It worked fine with low user load, but days with heavy load the system went down all the day.

After some tests we moved to Varnish Cache and now everything works better.

The problem is that only Unix environment is supported, a new varnish windows cygwin-based version exists, but I don't now if is suitable for production environment:

It's not a bad thing. I've been using it long time ago. It works.

But you should know there are now really better alternatives when handling caches in front of an apache server. One of theses nice tools is Varnish . You will have very fine tunnings available.

Here's a deep explanation of why varnish is a modern tool and why this new way of using the OS (and not separating memory and disk in spirit) is good : http://www.varnish-cache.org/trac/wiki/ArchitectNotes

About the headers you should use theses headers to communicate with Varnish (or other things, like urls) and let the cache tool handle the final headers.

If you can have a direct access on your server and not just a restricted apache access try it. Now if you can only access apache configuration... but ... c:/cacheroot , you're using a windows server in production? You'll need an Unix-like system for varnish preferably 64bits.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM