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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e6b0d716631d6db9e787441b6ce1f5193e04c5fb
4
- data.tar.gz: bbb4af70d8f7895d85064e26c86e74f6a3de3fce
3
+ metadata.gz: 8da7e26b7d4cb9f018cdd414b8a7b54e8bd5eef0
4
+ data.tar.gz: dc3f9f4bb5a7e3d40a95a9c79d79ee703124c6cd
5
5
  SHA512:
6
- metadata.gz: f19658678112cc77d94191ebc2fbfdc2842512aa8af7b3aeb38a4c6fa59c51e63311d4374093911dee644f8cf84a884118181eabc31e208d47942f71ec9734d0
7
- data.tar.gz: 5b0c97d26fb52801a45fcb52efadd1d6e0b6f8f5e7d973ca95d28914c28e64261cc66b3bf10bb84c50e55cb156ccbecfeead50e96596562408feba599d90b609
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
 
@@ -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
 
@@ -3,5 +3,5 @@
3
3
  module Restful
4
4
  ##
5
5
  # Sets the library version
6
- VERSION = '0.0.4'
6
+ VERSION = '0.0.5'
7
7
  end
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
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-10 00:00:00.000000000 Z
11
+ date: 2013-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails