add config files
[ckanext-datagovau.git] / admin / default.vcl
CKAN data.gov.au 1 # This is a basic VCL configuration file for varnish. See the vcl(7)
2 # man page for details on VCL syntax and semantics.
3 #
4 # Default backend definition. Set this to point to your content
5 # server.
6 #
7 backend default {
8 .host = "127.0.0.1";
9 .port = "8080";
10 }
11
12 sub vcl_fetch {
13 set beresp.grace = 1h;
14
15 if (beresp.http.content-type ~ "(text|application)") {
16 set beresp.do_gzip = true;
17 }
18 if (req.url ~ "\.(png|gif|jpg|jpeg|swf|css|js|woff|eot)$") {
19 unset beresp.http.set-cookie;
20 }
21 }
22 sub vcl_recv {
23 if (req.url ~ "^/_tracking") {
24 return (pass);
25 }
26 if (req.url ~ "\.(png|gif|jpg|jpeg|swf|css|js|woff|eot)$") {
27 return(lookup);
28 }
29 if (req.http.Cookie) {
30 set req.http.Cookie = regsuball(req.http.Cookie, "(^|; ) *__utm.=[^;]+;? *", "\1"); # removes all cookies named __utm? (utma, utmb...) - tracking thing
31
32 if (req.http.Cookie == "") {
33 remove req.http.Cookie;
34 }
35 }
36 }
37 sub vcl_deliver {
38 if (!resp.http.Vary) {
39 set resp.http.Vary = "Accept-Encoding";
40 } else if (resp.http.Vary !~ "(?i)Accept-Encoding") {
41 set resp.http.Vary = resp.http.Vary + ",Accept-Encoding";
42 }
43 if (obj.hits > 0) {
44 set resp.http.X-Cache = "HIT";
45 } else {
46 set resp.http.X-Cache = "MISS";
47 }
48 }
49
50 #
51 # Below is a commented-out copy of the default VCL logic. If you
52 # redefine any of these subroutines, the built-in logic will be
53 # appended to your code.
54 # sub vcl_recv {
55 # if (req.restarts == 0) {
56 # if (req.http.x-forwarded-for) {
57 # set req.http.X-Forwarded-For =
58 # req.http.X-Forwarded-For + ", " + client.ip;
59 # } else {
60 # set req.http.X-Forwarded-For = client.ip;
61 # }
62 # }
63 # if (req.request != "GET" &&
64 # req.request != "HEAD" &&
65 # req.request != "PUT" &&
66 # req.request != "POST" &&
67 # req.request != "TRACE" &&
68 # req.request != "OPTIONS" &&
69 # req.request != "DELETE") {
70 # /* Non-RFC2616 or CONNECT which is weird. */
71 # return (pipe);
72 # }
73 # if (req.request != "GET" && req.request != "HEAD") {
74 # /* We only deal with GET and HEAD by default */
75 # return (pass);
76 # }
77 # if (req.http.Authorization || req.http.Cookie) {
78 # /* Not cacheable by default */
79 # return (pass);
80 # }
81 # return (lookup);
82 # }
83 #
84 # sub vcl_pipe {
85 # # Note that only the first request to the backend will have
86 # # X-Forwarded-For set. If you use X-Forwarded-For and want to
87 # # have it set for all requests, make sure to have:
88 # # set bereq.http.connection = "close";
89 # # here. It is not set by default as it might break some broken web
90 # # applications, like IIS with NTLM authentication.
91 # return (pipe);
92 # }
93 #
94 # sub vcl_pass {
95 # return (pass);
96 # }
97 #
98 # sub vcl_hash {
99 # hash_data(req.url);
100 # if (req.http.host) {
101 # hash_data(req.http.host);
102 # } else {
103 # hash_data(server.ip);
104 # }
105 # return (hash);
106 # }
107 #
108 # sub vcl_hit {
109 # return (deliver);
110 # }
111 #
112 # sub vcl_miss {
113 # return (fetch);
114 # }
115 #
116 # sub vcl_fetch {
117 # if (beresp.ttl <= 0s ||
118 # beresp.http.Set-Cookie ||
119 # beresp.http.Vary == "*") {
120 # /*
121 # * Mark as "Hit-For-Pass" for the next 2 minutes
122 # */
123 # set beresp.ttl = 120 s;
124 # return (hit_for_pass);
125 # }
126 # return (deliver);
127 # }
128 #
129 # sub vcl_deliver {
130 # return (deliver);
131 # }
132 #
133 # sub vcl_error {
134 # set obj.http.Content-Type = "text/html; charset=utf-8";
135 # set obj.http.Retry-After = "5";
136 # synthetic {"
137 # <?xml version="1.0" encoding="utf-8"?>
138 # <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
139 # "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
140 # <html>
141 # <head>
142 # <title>"} + obj.status + " " + obj.response + {"</title>
143 # </head>
144 # <body>
145 # <h1>Error "} + obj.status + " " + obj.response + {"</h1>
146 # <p>"} + obj.response + {"</p>
147 # <h3>Guru Meditation:</h3>
148 # <p>XID: "} + req.xid + {"</p>
149 # <hr>
150 # <p>Varnish cache server</p>
151 # </body>
152 # </html>
153 # "};
154 # return (deliver);
155 # }
156 #
157 # sub vcl_init {
158 # return (ok);
159 # }
160 #
161 # sub vcl_fini {
162 # return (ok);
163 # }
164