简体   繁体   English

在Apache中使用mod_disk_cache?

[英]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. 我想在Apache中使用mod_disk_cache将xml feed缓存到一个文件夹中,然后直接从该文件夹中进行投放。 These are feeds dynamically created by php - but not changing very often. 这些是由php动态创建的供稿-但不会经常更改。 I want the caching at the htaccess level to avoid any strain/call to php and keep server stress to a minimum. 我希望在htaccess级别进行缓存以避免对PHP造成任何压力/调用,并将服务器压力降至最低。

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

httpd.apache.org/docs/2.2/mod/mod_disk_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. 我还将在xml中发送Expires:和Last-Modified:标头。

Think this will give me the desired solution and filling that cache folder and avoiding calls to php? 认为这将为我提供所需的解决方案,并填充该缓存文件夹并避免调用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. 我过去在Unix环境中将Apache与mod_cache一起使用。 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. 经过一些测试后,我们移至Varnish Cache,现在一切正常。

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: 问题是仅支持Unix环境,存在基于cygwin的新清漆Windows版本,但是现在不适合生产环境:

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. 但是您应该知道,现在在处理Apache服务器之前的缓存时,确实有更好的选择。 One of theses nice tools is Varnish . 这些不错的工具之一是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 这是有关为什么清漆是现代工具以及为什么使用操作系统(而不是在本质上分离内存和磁盘)的这种新方式很好的深入解释: 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. 关于标题,您应该使用这些标题与Varnish(或其他内容,例如url)进行通信,并让缓存工具处理最终的标题。

If you can have a direct access on your server and not just a restricted apache access try it. 如果您可以直接访问服务器,而不仅仅是受限制的apache访问,请尝试一下。 Now if you can only access apache configuration... but ... c:/cacheroot , you're using a windows server in production? 现在,如果您只能访问apache配置...但是... c:/ cacheroot ,您正在生产中使用Windows服务器? You'll need an Unix-like system for varnish preferably 64bits. 您将需要一个类似Unix的系统,最好使用64位清漆。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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