Module: Nomo::ConditionalGet

Extended by:
ActiveSupport::Concern
Defined in:
lib/nomo/conditional_get.rb

Instance Method Summary collapse

Instance Method Details

#fresh_when(record_or_options, additional_options = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/nomo/conditional_get.rb', line 5

def fresh_when(record_or_options, additional_options = {})
  if record_or_options.is_a? Nomo::Page
    nomo_page = record_or_options

    record_or_options = { etag: nomo_page.cache_key,
                          last_modified: nomo_page.last_modified }

    if nomo_page.realtime?
      response.headers['Nomo-Key'] = nomo_page.key
      response.headers['Nomo-LastModified'] = nomo_page.last_modified.to_f
    end
  end

  super
end