Skip to content

pilhofer/sinatra-cache

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Page Caching for Sinatra, with added options

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published