Sha256: 179ba30e0facdf18681bc1f9b2a9aa570b42aa45eab830b398ecfb0cb70f37e0

Contents?: true

Size: 702 Bytes

Versions: 2

Compression:

Stored size: 702 Bytes

Contents

module Storefront
  module CacheHelper
    def optional_cache(key, &block)
      cache(key, &block) unless session[:disable_caching]
    end
    
    def conditional_cache(key, options = {}, &block)
      condition = true
      condition = false if options.has_key?(:if) && options[:if] != true
      if condition
        cache(key, &block)
      else
        haml_concat capture_haml(&block)
      end
    end
    
    def set_cache_buster
      if request.xhr?
        response.headers["Cache-Control"] = "no-cache, no-store, max-age=0, must-revalidate"
        response.headers["Pragma"] = "no-cache"
        response.headers["Expires"] = "Fri, 01 Jan 1990 00:00:00 GMT"
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
storefront-0.2.1 lib/storefront/helpers/cache_helper.rb
storefront-0.2.0 lib/storefront/helpers/cache_helper.rb