I am running Webricks/Thin server locally for my development environment however i couldn't get to return Etag in my response.
I've tried various options suggested on SO to add Etag or ConditionalGet rack middleware components but to no avail. Here is the snippet on my development.rb file
config.middleware.use Rack::Cors do
allow do
origins 'xyz:3000', 'abc:3000'
resource '*', :headers => :any, :methods => [:get, :post, :options]
end
config.middleware.insert_before(Rack::Cors, Rack::ConditionalGet)
config.consider_all_requests_local = true
config.action_controller.perform_caching = true
Here is the sample response header from a request and thats missing the Etag header or HTTP_IF_NONE_MATCH and HTTP_IF_MODIFIED_SINCE headers and thus all requests return 200 OK and never the 304 Not Modified which
> curl --head -I mylocalhosturl
HTTP/1.1 200 OK
Last-Modified: Mon, 04 Feb 2013 23:49:11 GMT
Content-Type: application/json; charset=utf-8
Cache-Control: must-revalidate, private, max-age=0
X-Meta-Request-Version: 0.2.1
X-Ua-Compatible: IE=Edge
X-Request-Id: a06b5c3aeff8191ad22ab7d23433b076
X-Runtime: 0.217688
X-Rack-Cache: miss
X-Miniprofiler-Ids: ["470heu3ps6wht3tuqgdr","qdjrpkjus6pzw6ed28ex","egfngxkdtl2f2m1w7r9n","b3dlozxj3hyb9bq2i2fi","k7x41fq7anewz5jf0nm1","unojexyqklkjdew8dkti","rjwo48jd8pw8c0h0jb38","82d8g9o6agzoam7acxgi","tk577xwtgtfn7u1mrvqo","e8ih8byjbm2jfmbyl5tf"]
Content-Length: 0
Server: WEBrick/1.3.1 (Ruby/1.9.3/2012-02-16)
Date: Mon, 03 Jun 2013 18:34:31 GMT
Connection: Keep-Alive
Set-Cookie: __profilin=p%3Dt; path=/
Set-Cookie: __profilin=p%3Dt; path=/
Set-Cookie: __profilin=p%3Dt; path=/
Interesting this is not an issue on production which uses similar configurations AFAIK but nginx/1.2.0 as the server. Any ideas on enabling Etags in rails development mode appreciated.