Fix ranged caching, reduce latency by allowing hit-for-pass, set default TTLs and cache homepage
This commit is contained in:
parent
69a18ddf7f
commit
f1c3802434
|
@ -22,7 +22,7 @@ sub vcl_recv {
|
|||
if (req.http.Upgrade ~ "(?i)websocket") {
|
||||
return (pipe);
|
||||
}
|
||||
if (req.http.Range || req.http.cache-control == "no-cache") {
|
||||
if (req.http.cache-control == "no-cache") {
|
||||
return (pass);
|
||||
}
|
||||
if (req.method == "GET" || req.method == "HEAD") {
|
||||
|
@ -51,27 +51,34 @@ sub vcl_pipe {
|
|||
return (pipe);
|
||||
}
|
||||
sub vcl_backend_response {
|
||||
set beresp.ttl = 30m;
|
||||
if (beresp.http.Set-Cookie) {
|
||||
return(pass);
|
||||
set beresp.do_stream = false;
|
||||
if ( beresp.http.Set-Cookie ||
|
||||
beresp.http.Cache-Control ~ "no-cache|no-store|private" ||
|
||||
beresp.http.Vary == "*") {
|
||||
set beresp.uncacheable = true;
|
||||
return(deliver);
|
||||
}
|
||||
set beresp.ttl = 120s;
|
||||
if (beresp.http.ETag || beresp.http.Last-Modified) {
|
||||
set beresp.keep = 4h;
|
||||
}
|
||||
if (beresp.status == 301) {
|
||||
set beresp.ttl = 24h;
|
||||
}
|
||||
if ( beresp.http.Cache-Control ~ "public" ||
|
||||
if ( bereq.http.Host == "redxen.eu" ||
|
||||
beresp.http.Cache-Control ~ "public" ||
|
||||
beresp.http.Content-Type ~ "text/css" ||
|
||||
beresp.http.Content-Type ~ "text/javascript" ||
|
||||
beresp.http.Content-Type ~ "image" ||
|
||||
beresp.http.Content-Type ~ "video" ||
|
||||
beresp.http.Content-Type ~ "audio" ||
|
||||
beresp.http.Content-Type ~ "font") {
|
||||
set beresp.ttl = 10m;
|
||||
set beresp.do_gzip = true;
|
||||
return (deliver);
|
||||
}
|
||||
return (pass);
|
||||
set beresp.uncacheable = true;
|
||||
return (deliver);
|
||||
}
|
||||
sub vcl_deliver {
|
||||
if (obj.hits > 0) {
|
||||
|
|
Reference in New Issue