環境
rails 6.0.3
説明
ajax
化した画面を表示後に、別画面へ遷移し、その後ブラウザの戻る
ボタンで画面を戻ると、
生のjsコード
が画面に表示される問題について。
ブラウザのキャッシュが残っていることが原因だったので、解決方法をメモとして下記に記載します。
該当のcontroller
#---------*** 前略 ***---------
before_action :set_cache_headers
#-------*** 中略 ***--------
private
def set_cache_headers
response.headers["Cache-Control"] = "no-store"
end
#---------*** 後略 ***---------
該当のcontroller
に上記を追加することで解決しました。
自分の場合、no-store
のみの指定で解決しましたが、これが正しいのかどうかが確かで無いので誤っていたらコメントをお願いします。