Sha256: 78b874b4c7c823c4a485751692fdd48fe7823ae6df6e1041c50aa86c41c478bf

Contents?: true

Size: 804 Bytes

Versions: 34

Compression:

Stored size: 804 Bytes

Contents

module Workarea
  module Storefront
    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['X-Flash-Messages'] ||= ''

        response.headers['Vary'] = 'X-Requested-With, X-Flash-Messages'
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
workarea-storefront-3.4.45 app/controllers/workarea/storefront/http_caching.rb
workarea-storefront-3.4.44 app/controllers/workarea/storefront/http_caching.rb
workarea-storefront-3.4.43 app/controllers/workarea/storefront/http_caching.rb
workarea-storefront-3.4.42 app/controllers/workarea/storefront/http_caching.rb
workarea-storefront-3.4.41 app/controllers/workarea/storefront/http_caching.rb
workarea-storefront-3.4.40 app/controllers/workarea/storefront/http_caching.rb
workarea-storefront-3.4.39 app/controllers/workarea/storefront/http_caching.rb
workarea-storefront-3.4.38 app/controllers/workarea/storefront/http_caching.rb
workarea-storefront-3.4.37 app/controllers/workarea/storefront/http_caching.rb
workarea-storefront-3.4.36 app/controllers/workarea/storefront/http_caching.rb
workarea-storefront-3.4.35 app/controllers/workarea/storefront/http_caching.rb
workarea-storefront-3.4.34 app/controllers/workarea/storefront/http_caching.rb
workarea-storefront-3.4.33 app/controllers/workarea/storefront/http_caching.rb
workarea-storefront-3.4.32 app/controllers/workarea/storefront/http_caching.rb
workarea-storefront-3.4.31 app/controllers/workarea/storefront/http_caching.rb
workarea-storefront-3.4.30 app/controllers/workarea/storefront/http_caching.rb
workarea-storefront-3.4.29 app/controllers/workarea/storefront/http_caching.rb
workarea-storefront-3.4.28 app/controllers/workarea/storefront/http_caching.rb
workarea-storefront-3.4.27 app/controllers/workarea/storefront/http_caching.rb
workarea-storefront-3.4.26 app/controllers/workarea/storefront/http_caching.rb