Sha256: f08a9fae7c054214150f0d564c86c137bfa74e761a0e5140dac6462708c11888

Contents?: true

Size: 851 Bytes

Versions: 5

Compression:

Stored size: 851 Bytes

Contents

module FastlyRails
  module CacheControlHeaders
    extend ActiveSupport::Concern

    # Sets Cache-Control and Surrogate-Control headers
    # Surrogate-Control is stripped at the cache, Cache-Control persists (in case of other caches in front of fastly)
    # Defaults are:
    #  Cache-Control: 'public, no-cache, s-maxage: 30 days'
    #  Surrogate-Control: 'max-age: 30 days
    # custom config example: 
    #  {cache_control: 'public, no-cache, maxage=xyz', surrogate_control: 'max-age: blah'}
    def set_cache_control_headers(max_age = FastlyRails.configuration.max_age, opts = {})
      request.session_options[:skip] = true    # no cookies
      response.headers['Cache-Control'] = opts[:cache_control] || "public, no-cache"
      response.headers['Surrogate-Control'] = opts[:surrogate_control] || "max-age=#{max_age}"
    end


  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
fastly-rails-0.1.5 lib/fastly-rails/action_controller/cache_control_headers.rb
fastly-rails-0.1.4 lib/fastly-rails/action_controller/cache_control_headers.rb
fastly-rails-0.1.3 lib/fastly-rails/action_controller/cache_control_headers.rb
fastly-rails-0.1.2 lib/fastly-rails/action_controller/cache_control_headers.rb
fastly-rails-0.1.1 lib/fastly-rails/action_controller/cache_control_headers.rb