0.0
No commit activity in last 3 years
No release in over 3 years
Refresh the content of your page with a given interval
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
~> 3.7

Runtime

>= 0
 Project Readme

rack-refresher

Rack middleware for authomatic page refresh

About

Refresh the content of your page with a given interval

Installation

  gem install rack-refresher

Set Up And Configuration

Add the middleware inclusion to the config.ru file (before the run Application directive):

  require "rack-refresher"

  use Rack::Refresher do |config|
    config.ajax  = true
    config.delay = 1000
  end

Configuration options:

  • config.ajax = true (Default: false) Refresh only the <body> tag of the page in background via AJAX. The page will be fully reloaded if this option is not set;

  • config.delay = 1000 (Default: 5000, alias: config.interval) Refresh interval defined in milliseconds. 1000 milliseconds == 1 second;

The middleware can be included several times. For example the following code will create 2 refreshers: the first one will refresh the page every 5 seconds via AJAX and the second one will refresh the page every 5 minutes via reload:

  require "rack-refresher"

  use Rack::Refresher do |config|
    config.ajax  = true
    config.delay = 5000 # Every 5 seconds
  end

  use Rack::Refresher do |config|
    config.delay = 300_000 # Every 5 minutes
  end