codeforamerica/ohana-web-search

View on GitHub
app/controllers/concerns/cacheable.rb

Summary

Maintainability
A
0 mins
Test Coverage
D
66%
module Cacheable
  def cache_page(field)
    return unless ENV.fetch('ENABLE_CACHING', nil) == 'true'

    fresh_when(
      etag: latest_commit_hash, last_modified: field, public: true
    )
  end

  def latest_commit_hash
    ENV.fetch('LATEST_COMMIT_HASH', nil)
  end
end