We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 660a171 + c9874e6 commit 26c04bbCopy full SHA for 26c04bb
rails/cache-control-in-rails.md
@@ -0,0 +1,22 @@
1
+# Cache Control in Rails
2
+
3
+Whenever we load a page in browser, it will stores a cached version of the page.
4
5
+So if users press the back buttons, the browser will simply load the cache version of the page.
6
7
+This can be an issues when there sensitive information involve.
8
9
+We can simply set the header `Cache-Control` in our `application_controller.rb`
10
11
+```ruby
12
+#application_controller
13
+ before_filter :set_as_private
14
15
+ protected
16
17
+ def set_as_private
18
+ response.headers['Cache-Control'] = 'no-cache, no-store'
19
+ end
20
+```
21
22
+In the case where you only need it in specific page, just use the `before_filter` in respective controller.
0 commit comments