Sha256: 22941a6ada8661424d9402016b9dd0fa42ce1caefcc243ab1fa93ab32e038dd1

Contents?: true

Size: 730 Bytes

Versions: 28

Compression:

Stored size: 730 Bytes

Contents

module Workarea
  module HttpCaching
    extend ActiveSupport::Concern

    included do
      after_action :set_vary_headers
      helper_method :http_caching?
    end

    def cache_page
      unless current_user.try(:admin?)
        expires_in Workarea.config.cache_expirations.http_cache, public: true if flash.blank?
        request.session_options[:skip] = true
        @http_caching = true
      end
    end

    def http_caching?
      !!@http_caching
    end

    private

    def set_vary_headers
      response.headers['X-Requested-With'] = request.headers['X-Requested-With'] || ''
      response.headers['Vary'] = 'X-Requested-With, X-Workarea-Segments'
      fresh_when(last_modified: Time.current)
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
workarea-core-3.5.27 app/controllers/workarea/http_caching.rb
workarea-core-3.5.26 app/controllers/workarea/http_caching.rb
workarea-core-3.5.25 app/controllers/workarea/http_caching.rb
workarea-core-3.5.23 app/controllers/workarea/http_caching.rb
workarea-core-3.5.22 app/controllers/workarea/http_caching.rb
workarea-core-3.5.21 app/controllers/workarea/http_caching.rb
workarea-core-3.5.20 app/controllers/workarea/http_caching.rb
workarea-core-3.5.19 app/controllers/workarea/http_caching.rb
workarea-core-3.5.18 app/controllers/workarea/http_caching.rb
workarea-core-3.5.17 app/controllers/workarea/http_caching.rb
workarea-core-3.5.16 app/controllers/workarea/http_caching.rb
workarea-core-3.5.15 app/controllers/workarea/http_caching.rb
workarea-core-3.5.14 app/controllers/workarea/http_caching.rb
workarea-core-3.5.13 app/controllers/workarea/http_caching.rb
workarea-core-3.5.12 app/controllers/workarea/http_caching.rb
workarea-core-3.5.11 app/controllers/workarea/http_caching.rb
workarea-core-3.5.10 app/controllers/workarea/http_caching.rb
workarea-core-3.5.9 app/controllers/workarea/http_caching.rb
workarea-core-3.5.8 app/controllers/workarea/http_caching.rb
workarea-core-3.5.7 app/controllers/workarea/http_caching.rb