Wednesday, March 23, 2011

HTML5 Offline

HTML5 provides two robust offline capabilities already implemented in popular mobile devices, such as the iPhone and Android, and on modern desktop browsers based on the Webkit and Gecko rendering engines.

The easiest way to use Rack::Offline is by using Rails::Offline in a Rails application.
In your router:
match "/application.manifest" => Rails::Offline
This will automatically cache all JavaScript, CSS, and HTML in your public
directory, and will cause the cache to be updated each request in development
mode.
You can fine-tune the behavior of Rack::Offline by using it directly:
offline = Rack::Offline.configure do
  cache "images/masthead.png"

  public_path = Rails.public_path
  Dir[public_path.join("javascripts/*.js")].each do |file|
    cache file.relative_path_from(public_path)
  end

  network "/"
end
https://github.com/wycats/rack-offline

No comments: