Sha256: c2554d0334b2eb84d4e48cf924b87b6805f2499e5d3469717b1ebef0b1610f06

Contents?: true

Size: 834 Bytes

Versions: 6

Compression:

Stored size: 834 Bytes

Contents

module FastlyRails
  module CacheControlHeaders
    extend ActiveSupport::Concern

    # Sets Cache-Control and Surrogate-Control HTTP 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'
    #  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

6 entries across 6 versions & 1 rubygems

Version Path
fastly-rails-0.7.1 lib/fastly-rails/action_controller/cache_control_headers.rb
fastly-rails-0.7.0 lib/fastly-rails/action_controller/cache_control_headers.rb
fastly-rails-0.6.0 lib/fastly-rails/action_controller/cache_control_headers.rb
fastly-rails-0.5.0 lib/fastly-rails/action_controller/cache_control_headers.rb
fastly-rails-0.4.1 lib/fastly-rails/action_controller/cache_control_headers.rb
fastly-rails-0.4.0 lib/fastly-rails/action_controller/cache_control_headers.rb