在 Apache 中使用 mod_disk_cache?

发布于 2024-10-10 08:57:44 字数 808 浏览 0 评论 0原文

我想在 apache 中使用 mod_disk_cache 将我的 xml feed 缓存到文件夹中并直接从该文件夹提供服务。 这些是由 php 动态创建的提要 - 但不会经常更改。 我希望在 htaccess 级别进行缓存,以避免对 php 造成任何压力/调用,并将服务器压力降至最低。

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

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

以前有人这样做过吗?对你有用吗? 我正在让我的服务器公司安装我需要的模块,然后我自己就可以尝试一下。

我希望使用类似的东西:

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

我也会在 xml 中发送 Expires: 和 Last-Modified: 标头。

认为这会给我所需的解决方案并填充该缓存文件夹并避免调用 php? 或者说这种方法全错了? 预先感谢您的任何指导

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

只是我以为 2024-10-17 08:57:44

我过去在 Unix 环境中使用过带有 mod_cache 的 Apache。在用户负载较低的情况下,它运行良好,但在负载较重的情况下,系统会整天瘫痪。

经过一些测试后,我们转向了 Varnish Cache,现在一切都工作得更好了。

问题是仅支持 Unix 环境,存在基于 cygwin 的新 varnish windows 版本,但我现在不知道是否适合生产环境:

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:

奢欲 2024-10-17 08:57:44

这并不是一件坏事。我很久以前就用过它。有用。

但您应该知道,在 apache 服务器前面处理缓存时,现在确实有更好的选择。 Varnish 就是这些不错的工具之一。您将可以使用非常精细的调音。

这里深入解释了为什么 varnish 是一种现代工具,以及为什么这种使用操作系统的新方式(而不是在精神上分离内存和磁盘)是好的:http://www.varnish-cache.org/trac/wiki/ArchitectNotes

关于标头,您应该使用这些标头与 Varnish 进行通信(或其他东西,像 urls)并让缓存工具处理最终的标头。

如果您可以直接访问您的服务器,而不仅仅是受限的 apache 访问,请尝试一下。现在,如果您只能访问 apache 配置...但是...c:/cacheroot,您在生产中使用的是 Windows 服务器吗?你需要一个类似 Unix 的 varnish 系统,最好是 64 位。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文