开发者

Using mod_disk_cache in Apache?

开发者 https://www.devze.com 2023-02-02 16:21 出处:网络
I want to use mod_disk_cache in apache to cache my xml feeds to a folder and serve direct from that folder.

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/do开发者_StackOverflow中文版cs/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:

  • http://varnish-cache.org/trac/wiki/VarnishOnCygwinWindows


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消