-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.ru
42 lines (36 loc) · 1.03 KB
/
config.ru
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#\ -s puma
require 'rack'
require 'rack/contrib/try_static'
require 'rack/deflater'
require 'rack/cache'
# Forces SSL on all requests
unless ENV['RACK_ENV'] == 'development'
require 'rack/ssl'
use Rack::SSL
end
use Rack::Cache,
:verbose => true,
:metastore => 'file:/var/cache/rack/meta',
:entitystore => 'file:/var/cache/rack/body'
# Enables compression of http responses, used in conjunction with `activate :gzip` in config.rb
use Rack::Deflater
ONE_WEEK = 604_800
# Serve files from the build directory
use Rack::TryStatic,
root: 'build',
urls: %w[/],
try: %w(.html index.html /index.html),
header_rules: [
[
%w(css js png jpg woff html),
{ 'Cache-Control' => "public, max-age=#{ONE_WEEK}" }
]
]
run lambda { |env|
four_oh_four_page = File.expand_path('../build/404/index.html', __FILE__)
[
404,
{'Content-Type' => 'text/html', 'Cache-Control' => "public, max-age=#{ONE_WEEK}"},
[ File.read(four_oh_four_page) ]
]
}