rack/rack-contrib — pull request #79 by pvdb (2013-11-02 12:13:11+00:00)
Title: Ensure duration_in_seconds - and hence max-age - has an integer value

This is a small change to ensure that the `max-age` value in the `Cache-Control` header is an **integer**, not a **float**; this is especially relevant when setting the `duration` option for `Rack::StaticCache` to part of a year _(instead of multiples of a year)_

This requirement is covered by RFC 2616; from http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.6

> Age values are non-negative decimal integers, representing time in seconds.

**example** - set duration to 1 week

```ruby
# use Rack::StaticCache,
...
:duration => 1.fdiv(52)
```

**before** - `max-age=606461.5384615385`

```
$ curl -I http://localhost:5000/images/logo.png
HTTP/1.1 200 OK
Content-Type: image/png
Cache-Control: max-age=606461.5384615385, public
Expires: Sat, 09 Nov 2013 12:03:38 GMT
Content-Length: 18025
```

**after** - `max-age=606461`

```
curl -I http://localhost:5000/images/logo.png
HTTP/1.1 200 OK
Content-Type: image/png
Cache-Control: max-age=606461, public
Expires: Sat, 09 Nov 2013 12:27:33 GMT
Content-Length: 18025
```