mirror of
https://github.com/sinatra/sinatra
synced 2023-03-27 23:18:01 -04:00
document cache_control
This commit is contained in:
parent
1996436204
commit
267579c8ee
1 changed files with 17 additions and 0 deletions
17
README.rdoc
17
README.rdoc
|
@ -916,6 +916,23 @@ Or use a session:
|
||||||
session[:secret]
|
session[:secret]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
=== Cache Control
|
||||||
|
|
||||||
|
Setting your headers correctly is the foundation for proper HTTP caching.
|
||||||
|
|
||||||
|
You can easily set the Cache-Control header with like this:
|
||||||
|
|
||||||
|
get '/' do
|
||||||
|
cache_control :public
|
||||||
|
"cache it!"
|
||||||
|
end
|
||||||
|
|
||||||
|
Pro tip: Set up caching in a before filter.
|
||||||
|
|
||||||
|
before do
|
||||||
|
cache_control :public, :must_revalidate, :max_age => 60
|
||||||
|
end
|
||||||
|
|
||||||
=== Sending Files
|
=== Sending Files
|
||||||
|
|
||||||
For sending files, you can use the <tt>send_file</tt> helper method:
|
For sending files, you can use the <tt>send_file</tt> helper method:
|
||||||
|
|
Loading…
Reference in a new issue