0

我有一个带有 Devise 和 Alchemy CMS 的应用程序,当我登录时,按钮 Login 应该更改为 Logout 但它没有。我认为启用了 HTTP 缓存。如果我注销,我会被重定向到主页,并且在请求标头中我可以看到:

/users/sign_out

Status Code: 302
cache-control:no-cache

但如果我转到另一个页面,按钮仍然显示“注销”。如果我刷新主页,我会在标题中看到:

/

Request Method:GET
Status Code:200  (from disk cache)
cache-control:public
last-modified:Mon, 17 Dec 2018 19:32:08 GMT

如果我登录并转到另一个页面,按钮会显示登录。在标题中,我看到了这个:

/一些/其他/网址

Request Method:GET
Status Code:200  (from disk cache)
cache-control:public
last-modified:Mon, 17 Dec 2018 19:32:08 GMT

有没有办法解决这个问题?

4

1 回答 1

0

我必须升级到 4.0-stable,它添加must_revalidate到标题和覆盖render_fresh_page?方法https://github.com/AlchemyCMS/alchemy_cms/blob/4.0-stable/app/controllers/alchemy/pages_controller.rb#L192

看起来像这样:

应用程序/控制器/炼金术/pages_controller_extension.rb

Alchemy::PagesController.class_eval do
  def render_fresh_page?
    flash.present? || !@page.cache_page? || stale?(etag: page_etag,
      last_modified: @page.published_at,
      public: !@page.restricted,
      template: 'pages/show')
  end
end
于 2018-12-18T15:14:51.587 回答