No need to revalidate if resource is final
This commit is contained in:
parent
e2b49a91d6
commit
505b2fb911
|
@ -16,7 +16,7 @@ module Travis::Api::App::Responders
|
|||
def cache_control
|
||||
if final?
|
||||
mode = endpoint.public? ? :public : :private
|
||||
endpoint.expires(31536000, mode, :must_revalidate) # 1 year
|
||||
endpoint.expires(31536000, mode) # 1 year
|
||||
else
|
||||
# FIXME: Chrome WTF?
|
||||
endpoint.cache_control :no_cache
|
||||
|
|
21
spec/unit/responders/service_spec.rb
Normal file
21
spec/unit/responders/service_spec.rb
Normal file
|
@ -0,0 +1,21 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Travis::Api::App::Responders::Service do
|
||||
class MyService < Travis::Api::App::Responders::Service
|
||||
end
|
||||
|
||||
let(:endpoint) { stub 'endpoint', public?: true }
|
||||
let(:resource) { stub 'resource', run: {} }
|
||||
let(:options) { {} }
|
||||
let(:service) { MyService.new(endpoint, resource, options) }
|
||||
|
||||
context 'with final resource' do
|
||||
before { resource.expects(:final?).returns(true) }
|
||||
|
||||
it 'caches resource for a year' do
|
||||
endpoint.expects(:expires).with(31536000, :public)
|
||||
service.apply
|
||||
end
|
||||
end
|
||||
|
||||
end
|
Loading…
Reference in New Issue
Block a user