Max Lukin
Max Lukin

Reputation: 135

Headers in Rails, Cache, Firefox impropriety

Folks! I have a problem, for example, user join on my page and do some actions, write comments, and push "Back" in Firefox, he looks old content (cache). I'm using Rails 2.3, but don't know, ho to fix it. I need that user push "back" in FF, he will see updated content, not from FF cache. Apologize for my english. :) Thank for advice.

Upvotes: 1

Views: 328

Answers (2)

equivalent8
equivalent8

Reputation: 14227

for Rails 3 and 4 you can try this gem https://github.com/equivalent/no_cache_control

Upvotes: 0

Vivek Dhayalan
Vivek Dhayalan

Reputation: 477

You can prevent the browser cache by calling (before_filter :prevent_browser_cache ) the following code:

def prevent_browser_cache
  headers["Pragma"] = "no-cache"
  headers["Cache-Control"] = "must-revalidate"   
  headers["Cache-Control"] = "no-cache"   
  headers["Cache-Control"] = "no-store"       
end

Upvotes: 2

Related Questions