【问题标题】:Rails page caching with Apache and capistrano使用 Apache 和 capistrano 进行 Rails 页面缓存
【发布时间】:2010-10-28 14:44:02
【问题描述】:

以下文章解释了使用 Nginx 在 Rails 中进行页面缓存。

http://blog.hasmanythrough.com/2008/1/30/segregated-page-cache-storage

我喜欢在我的应用中实现这个解决方案,但在 Apache 上。 所以,主要的街区/路线是

if (-f $request_filename) { 休息; } if (-f /cache$request_filename) { 重写 (.*) /cache$1 中断; 休息; } if (-f /cache$request_filename.html) { 重写 (.*) /cache$1.html 中断; 休息; }

上述 Nginx 相关代码的 Apache 等价物可能是什么?

【问题讨论】:

    标签: ruby-on-rails apache mod-rewrite nginx


    【解决方案1】:

    这是我正在使用的:

    RewriteEngine On
    RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
    RewriteRule ^/$ /cache/index.html [QSA]
    RewriteRule ^([^.]+)$ /cache$1.html [QSA]
    

    第二行在重定向之前检查缓存文件是否存在,否则会让请求通过 Rails。

    【讨论】:

      猜你喜欢
      • 2011-08-14
      • 2016-05-26
      • 2012-01-01
      • 1970-01-01
      • 2011-01-21
      • 1970-01-01
      • 2012-08-31
      • 2021-11-27
      • 2012-01-28
      相关资源
      最近更新 更多