-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e8d4332
commit 834d603
Showing
1 changed file
with
3 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,14 @@ | ||
require 'rubygems' | ||
require 'rack' | ||
require 'rack/contrib/static_cache' | ||
require 'rack/contrib/try_static' | ||
require 'rack/contrib/response_headers' | ||
|
||
# Properly compress the output if the client can handle it | ||
use Rack::Deflater | ||
|
||
use Rack::StaticCache, | ||
root: 'build', | ||
urls: ['/assets/stylesheets', '/assets/javascripts', '/assets/fonts'] | ||
|
||
# Serve files from the build directory | ||
use Rack::TryStatic, | ||
root: 'build', | ||
urls: %w[/], | ||
try: ['.html', 'index.html', '/index.html'], | ||
cache_control: 'public, max-age=2592000' | ||
|
||
use Rack::ResponseHeaders do |headers| | ||
headers['Content-Type'] = 'text/html; charset=utf-8' if headers['Content-Type'] == 'text/html' | ||
|
||
# For anything that matches below this point, we set the surrogate key | ||
# for Fastly so that we can quickly purge all the pages without touching | ||
# the static assets. | ||
headers['Surrogate-Key'] = 'page' | ||
end | ||
try: ['.html', 'index.html', '/index.html'] | ||
|
||
run lambda{ |env| | ||
four_oh_four_page = File.expand_path('../build/404/index.html', __FILE__) | ||
four_oh_four_page = File.expand_path("../build/404/index.html", __FILE__) | ||
[ 404, { 'Content-Type' => 'text/html'}, [ File.read(four_oh_four_page) ]] | ||
} |