…the request matches the ETag value it calculates from the object you pass it, sets the Response to be a Not Modified, which causes Rails to bypass rendering the view.
You can use either fresh_when or stale? , depending on how your code is structured. The Rails documentation example for using fresh_when looks like this:
1 2 3 4 def show @ article = Article .find(params[ :id ]) fresh_when( :etag => @ article , :last_modified => …
def response @ response ||= begin status, headers, body = @application.call(request.env) Rack::Response.new(body, status, headers) end end end end end
The key change here is that by introducing the Mobile::Format::Responder class that encapsulates environment , I can more easily perform an extract method refactoring and improve the readability of this code. Additionally, each time that this middleware is invoked, I'm guaranteed to have …
…visibility to the appropriate AJAX events. Also, on success replace the content of # response with the response data. jQuery(function($) { // create a convenient toggleLoading function var toggleLoading = function() { $("#loading").toggle() };
$("#tool-form") .bind("ajax:loading", toggleLoading) .bind("ajax:complete", toggleLoading) .bind("ajax:success", function(data, status, xhr) { $("#response").html(status); …
3. Server Creates Response from Cached Fragments and Sends It
The server code loads up enough of the data needed by the page to use to find the fragments of the page that are cached and uses those fragments to build the response rather than running all of the rendering code. Depending on how you decide where to perform caching, a lot of the pieces of the page can be shared between users, and can be cached for a very long time. The longer the fragments are cached, the lower the total cost …
…to be part of the regular working schedule. In this great talk on "Resilient Response in Complex Systems" , which sparked this outburst you're currently reading (thank you, John Allspaw, you're inspiring!), John talks about Game Days at Etsy.
On Game Day, some component of the production system, I repeat, production system, is intentionally caused to fail. The purpose is to get people into the habit of dealing with failure, to get them out of the comfort …
So now let's call our provider api: @ response = @access_token.get('/api/timenow') @ info = @response.body
You should get back a json object:
Yippee!!!
Recap
So this concludes our whirlwind tour of OAuth from a provider and consumer side. I am leaving the following enhancements for you to do on your own:
provider logout
provider user registration
provider view of all registered applications for a given user
provider view of all tokens for a …
@ response = Net::HTTP.new(url.host, url.port).start do |http| http.request(request) end @parsed_response = Nokogiri::XML(@response.body) end
Then 'I receive a HTTP 200' do @response.code.to_i.should == 200 end
Then 'I should see "$xpath" in the response XML' do |xpath| @parsed_response.xpath(xpath).should_not be_empty, "could not find #{xpath} in: #{@response.body.inspect}" end
We parse the response using Nokogiri and check the response …
Looking good Vanity 1.8.0 is out : support for Rails 3.2 and many many bug fixes All thanks to @ dougcole who pulled it together.
Failsafe Etsy shares their experience with Resilient Response In Complex Systems .
Must watch Last week I shared a link to this presentation , here's the video for the brilliant The Mythical Team Month .
Brewing CoffeeScript Cookbook is full of community recipes of your favorite (or hated) JS dialect.
Request and Response streaming should be the default
Connections to backend servers should be persistent
Communication with backend servers should be message-oriented
Communication between clients and backends should be bi-directional
Make SPDY the default, embrace dynamic topologies
The first step towards these goals is to recognize that translating SPDY to HTTP is a convenient path in the short term, but exactly the wrong path in the long term. SPDY offers multiplexing, …
…controller = UsersController.new @ request = ActionController::TestRequest.new @ response = ActionController::TestResponse.new @ user = User.find(:first) end
should_be_restful do |resource| resource.parent = :country resource.create.params = { :name => "bob", :email => 'bob@bob.com', :age => 13} resource.update.params = { :name => "sue" } end end
Should be restful is very configurable, but as the name states, …