Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

draft some docs around the http caching helpers

  • Loading branch information...
commit 61ef53d7b80fb56273d3f953a3fd133ddfb6b0cb 1 parent ccb66b0
@sr sr authored
Showing with 33 additions and 0 deletions.
  1. +33 −0 README.rdoc
View
33 README.rdoc
@@ -462,6 +462,39 @@ You can also use it with the +content_type+ helper:
content_type :foo
+== Caching
+
+Sinatra provides four HTTP caching helpers:
+
+ cache_control :public, :must_revalidate, :max_age => 60
+
+translates into:
+
+ headers['Cache-Control'] = 'public, must-revalidate, max-age=60'
+
+And +expires+:
+
+ expires 500, :public, :must_revalidate
+
+which translates into:
+
+ headers['Cache-Control'] = 'public, must-revalidate, max-age=60'
+ headers['Expires'] = 'Mon, 08 Jun 2009 08:50:17 GMT'
+
+The +last_modified+ helper sets the Last-Modified HTTP header and immediately
++halt+ when the conditional GET matches:
+
+ last_modified Time.now
+
+The +etag+ helper works similarly except it relies on the ETag and
+If-None-Match HTTP headers.
+
+ etag "2c17f0b3ba37410016aaa4dcad475e6d"
+
+See also:
+* {Rack::Cache}[http://rtomayko.github.com/rack-cache/]
+* {Caching Tutorial for Web Authors and Webmasters}[http://www.mnot.net/cache_docs/]
+
== Rack Middleware
Sinatra rides on Rack[http://rack.rubyforge.org/], a minimal standard
Please sign in to comment.
Something went wrong with that request. Please try again.