added varnish response cacheing

okor vor 13 Jahren
Ursprung
Commit
09466a99dc
2 geänderte Dateien mit 20 neuen Zeilen und 2 gelöschten Zeilen
  1. 12 2
      main.rb
  2. 8 0
      public/css/styles.css

+ 12 - 2
main.rb

@@ -4,26 +4,33 @@ require 'haml'
4 4
 require 'json'
5 5
 require 'ostruct'
6 6
 
7
+
7 8
 helpers do
8 9
 
9
-  def cache_for(mins = 1)
10
+  def cache_for_day
10 11
     if settings.environment != :development
11
-      response['Cache-Control'] = "public, max-age=#{60*mins}"
12
+      response['Cache-Control'] = "public, max-age=86400"
12 13
     end
13 14
   end
14 15
 
15 16
 end
16 17
 
18
+
17 19
 get '/' do
20
+	cache_for_day
18 21
 	haml :index
19 22
 end
20 23
 
24
+
21 25
 get '/ip.json' do
22 26
 	{ :ip => request.ip }.to_json
23 27
 end
24 28
 
29
+
25 30
 get '/lookup' do
26 31
 	begin
32
+		cache_for_day
33
+
27 34
 		@lookup_info = Whois.query(params[:url])
28 35
 		admin_contacts = Hash[@lookup_info.admin_contacts[0].each_pair.to_a]
29 36
 		technical_contacts = Hash[@lookup_info.technical_contacts[0].each_pair.to_a]
@@ -45,9 +52,12 @@ end
45 52
 
46 53
 get '/lookup.json' do
47 54
 	begin
55
+		cache_for_day
56
+
48 57
 		@lookup_info = Whois.query(params[:url])
49 58
 		admin_contacts = Hash[@lookup_info.admin_contacts[0].each_pair.to_a]
50 59
 		technical_contacts = Hash[@lookup_info.technical_contacts[0].each_pair.to_a]
60
+
51 61
 		content_type :json
52 62
 		{ :domain => @lookup_info.domain,
53 63
 			:created_on => @lookup_info.created_on,

+ 8 - 0
public/css/styles.css

@@ -1,4 +1,12 @@
1
+@font-face {
2
+  font-family: 'Orbitron';
3
+  font-style: normal;
4
+  font-weight: 400;
5
+  src: local('Orbitron'), url('/fonts/orbitron_medium') format('opentype');
6
+}
7
+
1 8
 body {
9
+  font-family: sans-serif;
2 10
   font-size: 14px;
3 11
   background: #dedede;
4 12
 }