Quantcast
Channel: CaelumObject Developers' Blog » cache
Viewing all articles
Browse latest Browse all 2

How restful results are handled in Restfulie with Rails

$
0
0

Using a backport from a Rails 3, Restfulie responders enhance your response without you even noticing.

Creating

First, the new 201 support with correct headers in one cute line, supported by the created responder:


@item = Item.create(params[:item])
respond_with @item, :status => :created

Rendering

Rendering a resource using a hypermedia based representation:


@item = Item.find(params[:id])
respond_with @item

Without any extra configuration, the cacheable responder will enhance your results with last modified headers.

Caching, expiration and 304

It’s also trivial to leverage your system by providing an expiration policy. Reverse proxies, intermediate caches and clients will benefit from caching and 304 results:


@items = Item.all
respond_with @items, :expires_in => 2.minutes

Of course, cache and 304 support is also handled on Restfulie’s client side implementation.

This is it.

Extreme simplicity is about achieving conventioned behavior with one line of code, custom ones with a longer line.

Trying to make http and hypermedia usage easier than it already is.

There are a few design issues related to module include-inheritance that will be improved prior to the next release.


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images