restful_controller 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.rdoc +7 -0
- data/lib/restful/actions.rb +2 -2
- data/lib/restful/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8da7e26b7d4cb9f018cdd414b8a7b54e8bd5eef0
|
4
|
+
data.tar.gz: dc3f9f4bb5a7e3d40a95a9c79d79ee703124c6cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac3a161f6f1445a27ecf4bbcedc0d42fc2ffb1deb93aeda422e0c5ab8eaad2b7a3f53e57c14033410841e4661f61d93511f7e4bb0eabad8f3108f41a35152ecc
|
7
|
+
data.tar.gz: 1f24400ed741590736d590ad495fe1733a7ae5e66e2d78cc31e9fb578f3da10128686a667837587ee2b57d562161bdd921a8ad3c0668af7a2ed5091c94144cb2
|
data/README.rdoc
CHANGED
@@ -143,6 +143,13 @@ proving a dual block for success and failure results from our action:
|
|
143
143
|
end
|
144
144
|
end
|
145
145
|
|
146
|
+
=== Rails caching
|
147
|
+
Index and show actions added using Restful makes use of Rails #stale? method, which sets the *etag* and *last_modified* response headers that helps client and Rails application to reuse content if this haven't changed.
|
148
|
+
|
149
|
+
For content that haven't changed, Rails returns a 304 not modified http state and on Rails server we avoid rendering this content and with this Rails do not send data back to the client. The client should reuse its cached version of it.
|
150
|
+
|
151
|
+
If content have changed then it is rendered and sent back to the client along with the updated headers.
|
152
|
+
|
146
153
|
== Helper methods
|
147
154
|
Restful add a set of handy methods that allows it to play nice with Rails view inheritance.
|
148
155
|
|
data/lib/restful/actions.rb
CHANGED
@@ -70,7 +70,7 @@ module Restful
|
|
70
70
|
# The instance variable name is a pluralization of the model name defined
|
71
71
|
# in the restful macro.
|
72
72
|
def index(options = {}, &block)
|
73
|
-
respond_with(collection, options, &block)
|
73
|
+
respond_with(collection, options, &block) if stale?(collection, last_modified: collection.maximum(:updated_at))
|
74
74
|
end
|
75
75
|
alias_method :index!, :index
|
76
76
|
|
@@ -145,7 +145,7 @@ module Restful
|
|
145
145
|
def show(options = {}, &block)
|
146
146
|
object = get_resource_ivar || find_resource
|
147
147
|
|
148
|
-
respond_with(object, options, &block)
|
148
|
+
respond_with(object, options, &block) if stale?(object)
|
149
149
|
end
|
150
150
|
alias_method :show!, :show
|
151
151
|
|
data/lib/restful/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: restful_controller
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mario Alberto Chavez
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-07-
|
11
|
+
date: 2013-07-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|