Page Caching for Sinatra, with added options
Switch branches/tags
Nothing to show
Pull request Compare This branch is 78 commits behind kematzy:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
test
.gitignore
LICENSE
README.textile

README.textile

Sinatra::Cache

Adds simple Page Caching to Sinatra

TODOs

NB! Very unfinished work, so use with care.

  1. Write tests
  2. Add logging output
  3. Move the configurations

Configuration

Example:


  1. toggle for cache functionality
    set :cache_enabled, true
  2. default extension for caching
    set :cache_page_extension, ‘.html’
  3. set Cache dir to Root of Public.
    set :cache_dir, ‘system/cache/’

Usage

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

Credits

Inspired by code from Rails & Merb
and sinatra-mailer