Class: HouseAccount::Engine

Inherits:
Rails::Engine
  • Object
show all
Defined in:
lib/houseaccount/engine.rb

Overview

Hooks the gem into a host app: serves its files, its error pages and its helpers.

Constant Summary collapse

PREFIXES =

The folders the design site publishes, served from this gem at the same paths so a page on an app and a page on the site link one file — this version's copy under its own prefix among them. Each keeps its slash: Rack::Static matches on start_with?, and /page would swallow /pages itself.

%W[/css/ /js/ /theme/ /font/ /logo/ /favicon/ /page/ /v#{VERSION}/].freeze
HEADERS =

An unversioned file is asked for again on every full load and answered 304 Not Modified while it stands, since its URL never changes between versions. A font, whose name carries a hash of its bytes, and anything under this version's prefix never change at all, so a browser may keep them for good.

[
  [:all, { 'cache-control' => 'no-cache' }],
  ['/font/', { 'cache-control' => 'public, max-age=31536000, immutable' }],
  ['/v', { 'cache-control' => 'public, max-age=31536000, immutable' }],
].freeze
DEVELOPMENT_HEADERS =

What a file is kept for while the gem is being worked on: not at all, since the version's copy is rewritten under the same name until it is released, and a browser told to keep it for a year would show yesterday's stylesheet on today's page.

HEADERS.first 1