I'm trying to use Varnish to show the non-logged in users a cached version of my website.
I'm able to perfectly detect if the user is logged in or out, but I can't cache pages without extensions.

There is no file extension because nginx is rewriting the URL to a php script(so caching .php does not work).

For example I'd like varnish to cache:
example.com
example.com/forum/
example.com/contact/

I have tried

```
if (req.request == "GET" && req.url ~ "^/") {
return(lookup);
}
if (req.request == "GET" && req.url ~ "") {
return(lookup);
}
if (req.request == "GET" && req.url ~ "/") {
return(lookup);
}

```

but nothing seems to work... any help?

EDIT:

It still gives me X-Cache: MISS whenever I go to a extensionless page...

Website is at <http://www.atherys.com>

And the current VCL is...

```
# This is a basic VCL configuration file for varnish.  See the vcl(7)
# man page for details on VCL syntax and semantics.
#
# Default backend definition.  Set this to point to your content
# server.
#
backend default {
.host = "127.0.0.1";
.port = "8080";
}

/* Only permit cluster to purge files from cache */
acl purge {
"localhost";
}

sub vcl_recv {
        /* Before anything else we need to fix gzip compression */
    if (req.http.Accept-Encoding) {
            if (req.url ~ "\.(jpg|png|gif|gz|tgz|bz2|tbz|mp3|ogg)$") {
                    # No point in compressing these
                    remove req.http.Accept-Encoding;
            } else if (req.http.Accept-Encoding ~ "gzip") {
                    set req.http.Accept-Encoding = "gzip";
            } else if (req.http.Accept-Encoding ~ "deflate") {
                    set req.http.Accept-Encoding = "deflate";
            } else {
                    # unknown algorithm
                    remove req.http.Accept-Encoding;
            }
    }

    if (req.request == "PURGE") {
            if (!client.ip ~ purge) {
                    error 405 "Not allowed.";
            }
            /* Always purge by URL rather than going via vcl_hash
            as it hashes other factors which break purging */
            purge_url(req.url);
            error 200 "Purged";
    }

    #Remove cookies,remove queries and cache everything from content.gazamo-cdn.com
    if (req.http.host == "content.gazamo-cdn.com") {
            remove req.http.Cookie;
            set req.url = regsub(req.url, "\?.*$", "");
    }

    #Atherys specific, if not logged in = cache; if logged in = pass
    if (req.http.host == "atherys.com" || req.http.host == "www.atherys.com") {
            if (req.http.Cookie ~ "xf_cache=1" && req.request == "GET") {
                    return(lookup);
                    if (req.request == "GET" && req.url ~ "^/") {
                            return(lookup);
                    }

            }
    }

    # always cache these items:

    if (req.request == "GET" && req.url ~ "\.(js|css)") {
            remove req.http.Cookie;
            return(lookup);
    }

    ## images
    if (req.request == "GET" && req.url ~ "\.(gif|jpg|jpeg|bmp|png|tiff|tif|ico|img|tga|wmf)$") {
            remove req.http.Cookie;
            return(lookup);
    }

    ## various other content pages
    if (req.request == "GET" && req.url ~ "\.(css|html)$") {
            remove req.http.Cookie;
            return(lookup);
    }

    ## multimedia
    if (req.request == "GET" && req.url ~ "\.(svg|swf|ico|mp3|mp4|m4a|ogg|mov|avi|wmv)$") {
            remove req.http.Cookie;
            return(lookup);
    }

    ## various other content pages
    if (req.request == "GET" && req.url ~ "\.(css|html)$") {
            remove req.http.Cookie;
            return(lookup);
    }

    ## multimedia
    if (req.request == "GET" && req.url ~ "\.(svg|swf|ico|mp3|mp4|m4a|ogg|mov|avi|wmv)$") {
            remove req.http.Cookie;
            return(lookup);
    }

    ## xml

    if (req.request == "GET" && req.url ~ "\.(xml)$") {
            remove req.http.Cookie;
            return(lookup);
    }

    #Do not cache
    if (req.request != "GET" && req.request != "HEAD") {
            return(pipe);
    }
    if (req.http.Authenticate || req.http.Authorization) {
            return(pass);
    }

    ### don't cache authenticated sessions
    #if (req.http.Cookie && req.http.Cookie ~ "authtoken=") {
    #        return(pipe);
    #}

}
sub vcl_deliver {
    if (obj.hits > 0) {
            set resp.http.X-Cache = "HIT";
    } else {
            set resp.http.X-Cache = "MISS";
    }
 }

```

Also, varnishlog:

```
0 CLI          - Rd ping
0 CLI          - Wr 200 PONG 1354732729 1.0
0 CLI          - Rd ping
0 CLI          - Wr 200 PONG 1354732732 1.0
12 SessionOpen  c 86.50.90.54 62847 :80
12 ReqStart     c 86.50.90.54 62847 1225125294
12 RxRequest    c GET
12 RxURL        c /forum/
12 RxProtocol   c HTTP/1.1
12 RxHeader     c Host: www.atherys.com
12 RxHeader     c User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64; rv:16.0) Gecko/20100101 Firefox/16.0
12 RxHeader     c Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
12 RxHeader     c Accept-Language: fi-fi,fi;q=0.8,en-us;q=0.5,en;q=0.3
12 RxHeader     c Accept-Encoding: gzip, deflate
12 RxHeader     c Connection: keep-alive
12 RxHeader     c Referer: http://www.atherys.com/forum/
12 RxHeader     c Cookie: xf_session=xxxxxxxxxxxxxxxx; xf_cache=1
12 RxHeader     c If-Modified-Since: Wed, 05 Dec 2012 18:27:16 GMT
12 VCL_call     c recv
12 VCL_return   c lookup
12 VCL_call     c hash
12 VCL_return   c hash
12 VCL_call     c miss
12 VCL_return   c fetch
14 BackendClose - default
14 BackendOpen  b default 127.0.0.1 59671 127.0.0.1 8080
12 Backend      c 14 default default
14 TxRequest    b GET
14 TxURL        b /forum/
14 TxProtocol   b HTTP/1.1
14 TxHeader     b Host: www.atherys.com
14 TxHeader     b User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64; rv:16.0) Gecko/20100101 Firefox/16.0
14 TxHeader     b Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
14 TxHeader     b Accept-Language: fi-fi,fi;q=0.8,en-us;q=0.5,en;q=0.3
14 TxHeader     b Referer: http://www.atherys.com/forum/
14 TxHeader     b Cookie: xf_session=xxxxxxxxx; xf_cache=1
14 TxHeader     b Accept-Encoding: gzip
14 TxHeader     b X-Varnish: 1225125294
14 RxProtocol   b HTTP/1.1
14 RxStatus     b 200
14 RxResponse   b OK
14 RxHeader     b Server: nginx
14 RxHeader     b Date: Wed, 05 Dec 2012 18:38:54 GMT
14 RxHeader     b Content-Type: text/html; charset=UTF-8
14 RxHeader     b Content-Length: 16013
14 RxHeader     b Connection: keep-alive
14 RxHeader     b Expires: Thu, 19 Nov 1981 08:52:00 GMT
14 RxHeader     b Cache-control: private, max-age=0
14 RxHeader     b Last-Modified: Wed, 05 Dec 2012 18:38:54 GMT
14 RxHeader     b Content-Encoding: gzip
14 RxHeader     b Vary: Accept-Encoding
12 TTL          c 1225125294 RFC 0 1354732734 0 0 0 0
12 VCL_call     c fetch
12 VCL_return   c deliver
12 ObjProtocol  c HTTP/1.1
12 ObjStatus    c 200
12 ObjResponse  c OK
12 ObjHeader    c Server: nginx
12 ObjHeader    c Date: Wed, 05 Dec 2012 18:38:54 GMT
12 ObjHeader    c Content-Type: text/html; charset=UTF-8
12 ObjHeader    c Expires: Thu, 19 Nov 1981 08:52:00 GMT
12 ObjHeader    c Cache-control: private, max-age=0
12 ObjHeader    c Last-Modified: Wed, 05 Dec 2012 18:38:54 GMT
12 ObjHeader    c Content-Encoding: gzip
12 ObjHeader    c Vary: Accept-Encoding
14 Length       b 16013
14 BackendReuse b default
0 CLI          - Rd ping
0 CLI          - Wr 200 PONG 1354732735 1.0
12 VCL_call     c deliver
12 VCL_return   c deliver
12 TxProtocol   c HTTP/1.1
12 TxStatus     c 200
12 TxResponse   c OK
12 TxHeader     c Server: nginx
12 TxHeader     c Content-Type: text/html; charset=UTF-8
12 TxHeader     c Expires: Thu, 19 Nov 1981 08:52:00 GMT
12 TxHeader     c Cache-control: private, max-age=0
12 TxHeader     c Last-Modified: Wed, 05 Dec 2012 18:38:54 GMT
12 TxHeader     c Content-Encoding: gzip
12 TxHeader     c Vary: Accept-Encoding
12 TxHeader     c Content-Length: 16013
12 TxHeader     c Date: Wed, 05 Dec 2012 18:38:54 GMT
12 TxHeader     c X-Varnish: 1225125294
12 TxHeader     c Age: 0
12 TxHeader     c Via: 1.1 varnish
12 TxHeader     c Connection: keep-alive
12 TxHeader     c X-Cache: MISS
12 Length       c 16013
12 ReqEnd       c 1225125294 1354732734.723051310 1354732735.044378281 0.000048399 0.204994202 0.116332769 
12 Debug        c "herding"
12 ReqStart     c 86.50.90.54 62847 1225125295
12 RxRequest    c GET
12 RxURL        c /cron.php?1354732734
12 RxProtocol   c HTTP/1.1
12 RxHeader     c Host: www.atherys.com
12 RxHeader     c User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64; rv:16.0) Gecko/20100101 Firefox/16.0
12 RxHeader     c Accept: image/png,image/*;q=0.8,*/*;q=0.5
12 RxHeader     c Accept-Language: fi-fi,fi;q=0.8,en-us;q=0.5,en;q=0.3
12 RxHeader     c Accept-Encoding: gzip, deflate
12 RxHeader     c Connection: keep-alive
12 RxHeader     c Referer: http://www.atherys.com/forum/
12 RxHeader     c Cookie: xf_session=xxxxxx; xf_cache=1
12 VCL_call     c recv
12 VCL_return   c lookup
12 VCL_call     c hash
12 VCL_return   c hash
12 VCL_call     c miss
12 VCL_return   c fetch
12 Backend      c 14 default default

```