How about:

```ruby
timeout = if cache_control_elements.assoc('must-revalidate') || cache_control_elements.assoc('no-cache')
  0
else
  max_age = cache_control_elements.assoc('max-age') ? max_age[1].to_i  : 0
end
```