Adds simple Page Caching to Sinatra
NB! Very unfinished work, so use with care.
- Write tests
- Add logging output
- Move the configurations
Example:
- toggle for cache functionality
set :cache_enabled, true- default extension for caching
set :cache_page_extension, ‘.html’set Cache dir to Root of Public.
set :cache_dir, ‘system/cache/’
Basic Page Caching into static HTML files
get '/contact' do
cache( erb( :contact, :layout => :layout))
end
Expiring old pages (ie: after POST or PUT events)
# not very good example
post '/contact' do
expire_cache( '/contact')
end
Inspired by code from Rails & Merb
and sinatra-mailer