2

There are several S.O. questions on this like:

But no mater what I do, what I override I'm still getting header (FireFox, Chrome, curl -V, ...any browser)

Cache-Control: must-revalidate, private, max-age=0

I tried

class ApplicationsController < ActionController::Base
  before_filter :no_store_cache
  after_filter :no_store_cache

  def no_store_cache
    response.headers["Cache-Control"] = "no-cache, no-store, max-age=0, must-revalidate"
    response.headers["Pragma"] = "no-cache"
    response.headers["Expires"] = '-1'
  end
end

I Tried to call this callback directly on ActionController::Base (https://github.com/equivalent/no_cache_control.git )

I Tried digging in rack-cache middle-ware overriding stuff trying to enforce the header

I've created my own middleware that was overriding header['Cache-Control'].

nothing works

Community
  • 1
  • 1
equivalent8
  • 13,754
  • 8
  • 81
  • 109

2 Answers2

2

With Rails 3.2 the gem no_cache_control only works when the rails app is booted in production mode. Can test this by booting your app in production mode with:

rails s -e production

Note: make sure you have your database.yml pointing somewhere valid for the production environment.

Joshua Pinter
  • 45,245
  • 23
  • 243
  • 245
David Barlow
  • 4,914
  • 1
  • 28
  • 24
  • ...hah, I'll be dammed, it works. Nice spot thank you for this – equivalent8 Dec 16 '14 at 10:09
  • 1
    it works for my "Staging" environment too(pretty much duplicate of Producion). So the premiss is that due to some Development environment configuration it is ignoring it – equivalent8 Dec 16 '14 at 10:12
0

Rails 7 now has a no_store method.

before_action :no_store
Kris
  • 19,188
  • 9
  • 91
  • 111