Disable HTTP caching application-wide (e.g. conditional GET)

11 views
Skip to first unread message

Jack Kinsella

unread,
Sep 22, 2019, 1:48:19 AM9/22/19
to Ruby on Rails: Core
I have a Rails 6 application that relies on public caching e.g. `expires_in 1.week, public: true`. These pages must undergo integration tests (Capybara/Headless Chrome), and some pages change state between test cases. In order to prevent sporadic, order-dependent test failures, I want to disable HTTP caching (i.e.  "Conditional GET") in my test suite.

My first intuition, based on the docs, was that setting `config.action_controller.perform_caching = false` would disable all caching, but this turned out to not be the case. Running `config.middleware.delete(Rack::ConditionalGet)` also didn't make a difference.

So:
1. Is there a clean way to do this?
2. If there _isn't_ a way, would there be any interest in a pull request implementing a configuration option, e.g. `config.action_controller.http_caching = false `? I'd be happy to contribute it, but only if you feel it's a potentially worthwhile addition.

Jack

Reply all
Reply to author
Forward
0 new messages