アクションキャッシュを使用してアクションをキャッシュし、次にrefreshという別のアクションを使用して手動で有効期限を切ろうとしています。 Railsのベストプラクティスはスイーパーを使うことだが、それもうまくいきません。これはWebBrickを使ってローカルでうまく動作しますが、Phusion Passengerを使用してApacheにデプロイすると、キャッシュが失効することはありません。 expire_actionは、キャッシュパスからインデックスを省略することで、間違った動作を期限切れにしているようです。Apacheにデプロイするときにexpire_actionが機能しない
bills_controller.rb
class BillsController < ApplicationController
caches_action :index
def index
...
end
def refresh
expire_action :action => :index
redirect_to :action => :index
end
Iはhttp://www.mysite.org/billsに移動すると、/log/production.logこれを示しています。私はhttp://www.mysite.org/refreshに移動するとき/ログ、そして
Started GET "/bills"
Rendered bills/index.html.erb
Write fragment views/www.mysite.org/bills/index
を/production.logはこれを示します:
Started GET "/bills/refresh"
Expire fragment views/www.mysite.org/bills <<<<Culprit?
Redirected to http://www.mysite.org/bills
Started GET "/bills"
Read fragment views/www.mysite.org/bills/index
Expireフラグメントビュー/ www.mysite.org/billsに/ index部分が含まれていないことに注意してください。私はこれがキャッシュが期限切れではない理由だと思うが、わからない。サイトの
私のApache設定は次のようになります。
<VirtualHost *:80>
ServerName www.mysite.org
DocumentRoot /var/www/html/mysite.org/public
<Directory /var/www/html/mysite.org/public>
AllowOverride all
Options -MultiViews
</Directory>
</VirtualHost>