readme changelog updated, stable tag updated 1.4.3
[varnish-caching-wordpress-plugin.git] / varnish-conf / v4 / lib / static.vcl
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
# static.vcl -- Static File Caching for Varnish

sub vcl_recv {
    if (req.method ~ "^(GET|HEAD)$" && req.url ~ "\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|pdf|txt|tar|wav|bmp|rtf|js|flv|swf|html|htm)(\?.*)?$") {
        # enable this if you want
        #if (req.url ~ "debug") {
        #    set req.http.X-VC-Debug = "true";
        #}
        # enable this if you need it
        #if (req.url ~ "nocache") {
        #    set req.http.X-VC-Cacheable = "NO:Not cacheable, nocache in URL";
        #    return(pass);
        #}
        set req.url = regsub(req.url, "\?.*$", "");
        # unset cookie only if no http auth
        if (!req.http.Authorization) {
            unset req.http.Cookie;
        }
        return(hash);
    }
}

sub vcl_backend_response {
    if (bereq.method ~ "^(GET|HEAD)$" && bereq.url ~ "\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|pdf|txt|tar|wav|bmp|rtf|js|flv|swf|html|htm)$") {
        # overwrite ttl with X-VC-TTL
        set beresp.http.X-VC-TTL = 24*60*60;
        set beresp.ttl = std.duration(beresp.http.X-VC-TTL + "s", 0s);
        set beresp.http.X-VC-Cacheable = "YES:Is cacheable, ttl: " + beresp.ttl;
    }
}

comments