I'm testing integration with purge (#1048000: nginx support) and I have it running, but I was wondering how to clear the cache of all devices, I tried adding multiple fastcgi_cache_purge inside the location directive, but it's a no go :/

Comments

omega8cc’s picture

Component: Code » Documentation

Just rm -f -r /var/lib/nginx/speed/* clears all Nginx caches.

attiks’s picture

I know that, the goal is to use expire and purge to do it in a controlled way, it's a bit expensive to clear all caches on every page edit.

nginx_advanced_include.conf:

location ~* ^/index\.php$ {
  fastcgi_cache speed;
  fastcgi_cache_min_uses 1;
  fastcgi_cache_key "$device$host$key_uri$cookie_OctopusCacheID";
  ....
}

It would be nice if we could do the following inside nginx_speed_purge.conf:

  location ~ /purge(/.*) {
    fastcgi_cache_purge speed normal$host$1$is_args$args;
    fastcgi_cache_purge speed mobile-other$host$1$is_args$args;
    ...
  }
omega8cc’s picture

Component: Documentation » Code
Category: support » bug

Ah, right, it no longer works after we introduced $device in the cache key. It is a bug then.

I didn't test it yet, but we probably can't use multiple fastcgi_cache_purge in the same location?

attiks’s picture

No, you can't :/

Related is the use of the cookie in the cache key, so I opened 2 issues:

omega8cc’s picture

So we should at least add 'normal' there to support non-mobile cache entries purging:

  location ~ /purge(/.*) {
    fastcgi_cache_purge speed normal$host$1$is_args$args;
  }
attiks’s picture

that's what i did and it works, but i'm still struggling with the clearing of the cache for non anon users, I googled a bit but since the filename is md5 of the URI i think this will be a problem.

omega8cc’s picture

I don't think it will be possible, as this md5 hash is stored only in the cache itself. Anyway, cache for logged in users is valid only for 5 minutes by default and skipped entirely after any POST request.

attiks’s picture

I created a feature request on the nginx forms to add fainer grained control on the cache filenames: http://forum.nginx.org/read.php?10,217748

omega8cc’s picture

Thanks. Let's see what they can do to support our crazy setup ;)

attiks’s picture

i think we need 4 purge methods, one for each device. the purge module support multiple servers, so should work?

location ~ /purgenormal(/.*) {
fastcgi_cache_purge speed normal$host$1$is_args$args;
}

omega8cc’s picture

Not sure how it is expected to fix the problem.

We force by default $conf['purge_proxy_urls'] = "http://127.0.0.1:8888/purge?purge_method=get"; and even if we will create separate locations (or even servers), how to make it to fire them all (for all devices) at once?

We probably need to fork the purge module to make that happen.

attiks’s picture

i didn't try it yet, just thinking out loud, but i think purge uses all defined servers, but i'll try it tomorrow.

omega8cc’s picture

Status: Active » Needs review
omega8cc’s picture

Status: Needs review » Reviewed & tested by the community

It seems it works as expected:

127.0.0.1 - - [18/Dec/2011:20:09:16 +0000] "GET /purge-normal/node/1 HTTP/1.1" 200 298 "-" "-"
127.0.0.1 - - [18/Dec/2011:20:09:16 +0000] "GET /purge-mobile-tablet/node/1 HTTP/1.1" 404 169 "-" "-"
127.0.0.1 - - [18/Dec/2011:20:09:16 +0000] "GET /purge-mobile-smart/node/1 HTTP/1.1" 404 169 "-" "-"
127.0.0.1 - - [18/Dec/2011:20:09:16 +0000] "GET /purge-mobile-other/node/1 HTTP/1.1" 404 169 "-" "-"
127.0.0.1 - - [18/Dec/2011:20:09:16 +0000] "GET /purge-normal/ HTTP/1.1" 200 292 "-" "-"
127.0.0.1 - - [18/Dec/2011:20:09:16 +0000] "GET /purge-mobile-tablet/ HTTP/1.1" 404 169 "-" "-"
127.0.0.1 - - [18/Dec/2011:20:09:16 +0000] "GET /purge-mobile-smart/ HTTP/1.1" 404 169 "-" "-"
127.0.0.1 - - [18/Dec/2011:20:09:16 +0000] "GET /purge-mobile-other/ HTTP/1.1" 404 169 "-" "-"
127.0.0.1 - - [18/Dec/2011:20:09:16 +0000] "GET /purge-normal/rss.xml HTTP/1.1" 404 169 "-" "-"
127.0.0.1 - - [18/Dec/2011:20:09:16 +0000] "GET /purge-mobile-tablet/rss.xml HTTP/1.1" 404 169 "-" "-"
127.0.0.1 - - [18/Dec/2011:20:09:16 +0000] "GET /purge-mobile-smart/rss.xml HTTP/1.1" 404 169 "-" "-"
127.0.0.1 - - [18/Dec/2011:20:09:16 +0000] "GET /purge-mobile-other/rss.xml HTTP/1.1" 404 169 "-" "-"
127.0.0.1 - - [18/Dec/2011:20:09:16 +0000] "GET /purge-normal/node HTTP/1.1" 404 169 "-" "-"
127.0.0.1 - - [18/Dec/2011:20:09:16 +0000] "GET /purge-mobile-tablet/node HTTP/1.1" 404 169 "-" "-"
127.0.0.1 - - [18/Dec/2011:20:09:16 +0000] "GET /purge-mobile-smart/node HTTP/1.1" 404 169 "-" "-"
127.0.0.1 - - [18/Dec/2011:20:09:16 +0000] "GET /purge-mobile-other/node HTTP/1.1" 404 169 "-" "-"
127.0.0.1 - - [18/Dec/2011:20:09:16 +0000] "GET /purge-normal/node/1 HTTP/1.1" 404 169 "-" "-"
127.0.0.1 - - [18/Dec/2011:20:09:16 +0000] "GET /purge-normal/ HTTP/1.1" 404 169 "-" "-"
127.0.0.1 - - [18/Dec/2011:20:09:16 +0000] "GET /purge-mobile-other/node/1 HTTP/1.1" 404 169 "-" "-"
127.0.0.1 - - [18/Dec/2011:20:09:16 +0000] "GET /purge-mobile-smart/node/1 HTTP/1.1" 404 169 "-" "-"
127.0.0.1 - - [18/Dec/2011:20:09:16 +0000] "GET /purge-mobile-tablet/node/1 HTTP/1.1" 404 169 "-" "-"
127.0.0.1 - - [18/Dec/2011:20:09:16 +0000] "GET /purge-mobile-tablet/node HTTP/1.1" 404 169 "-" "-"
127.0.0.1 - - [18/Dec/2011:20:09:16 +0000] "GET /purge-normal/node HTTP/1.1" 404 169 "-" "-"
127.0.0.1 - - [18/Dec/2011:20:09:16 +0000] "GET /purge-mobile-other/rss.xml HTTP/1.1" 404 169 "-" "-"
127.0.0.1 - - [18/Dec/2011:20:09:16 +0000] "GET /purge-mobile-smart/rss.xml HTTP/1.1" 404 169 "-" "-"
127.0.0.1 - - [18/Dec/2011:20:09:16 +0000] "GET /purge-mobile-tablet/rss.xml HTTP/1.1" 404 169 "-" "-"
127.0.0.1 - - [18/Dec/2011:20:09:16 +0000] "GET /purge-normal/rss.xml HTTP/1.1" 404 169 "-" "-"
127.0.0.1 - - [18/Dec/2011:20:09:16 +0000] "GET /purge-mobile-other/ HTTP/1.1" 404 169 "-" "-"
127.0.0.1 - - [18/Dec/2011:20:09:16 +0000] "GET /purge-mobile-smart/ HTTP/1.1" 404 169 "-" "-"
127.0.0.1 - - [18/Dec/2011:20:09:16 +0000] "GET /purge-mobile-tablet/ HTTP/1.1" 404 169 "-" "-"
127.0.0.1 - - [18/Dec/2011:20:09:16 +0000] "GET /purge-mobile-other/node HTTP/1.1" 404 169 "-" "-"
127.0.0.1 - - [18/Dec/2011:20:09:16 +0000] "GET /purge-mobile-smart/node HTTP/1.1" 404 169 "-" "-"
v189q:~# curl -vv -H "Host:purge.demo.aegir.cc" "http://127.0.0.1:8888/purge-normal/node/1"
* About to connect() to 127.0.0.1 port 8888 (#0)
*   Trying 127.0.0.1... connected
* Connected to 127.0.0.1 (127.0.0.1) port 8888 (#0)
> GET /purge-normal/node/1 HTTP/1.1
> User-Agent: curl/7.18.2 (x86_64-pc-linux-gnu) libcurl/7.18.2 OpenSSL/0.9.8g zlib/1.2.3.3 libidn/1.8 libssh2/0.18
> Accept: */*
> Host:purge.demo.aegir.cc
> 
< HTTP/1.1 200 OK
< Server: nginx/1.0.11
< Date: Sun, 18 Dec 2011 20:07:14 GMT
< Content-Type: text/html
< Content-Length: 298
< Connection: keep-alive
< 
<html>
<head><title>Successful purge</title></head>
<body bgcolor="white">
<center><h1>Successful purge</h1>
<br>Key : normalpurge.demo.aegir.ccGET/node/1
<br>Path: /var/lib/nginx/speed/1b/95/39/75ad330db72eb9e2c778aecd1039951b
</center>
<hr><center>nginx/1.0.11</center>
</body>
</html>
* Connection #0 to host 127.0.0.1 left intact
* Closing connection #0
v189q:~# 

127.0.0.1 - - [18/Dec/2011:20:07:14 +0000] "GET /purge-normal/node/1 HTTP/1.1" 200 298 "-" "curl/7.18.2 (x86_64-pc-linux-gnu) libcurl/7.18.2 Op
enSSL/0.9.8g zlib/1.2.3.3 libidn/1.8 libssh2/0.18"
omega8cc’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.