Welcome! Log In Create A New Profile

Advanced

Finer grained control on caching

Posted by attiks 
Finer grained control on caching
November 03, 2011 04:37AM
We are using cache for anonymous users and authenticated users, this is done by settings a cookie for authenticated users and using a fastcgi_cache_key like this: fastcgi_cache_key "$host$key_uri$cookie_OctopusCacheID"; The problem is that we are not able to clear the cache for both anonymous users and authenticated users (using ngx_cache_purge), we can clear the cache for anonymous users without a problem since $cookie_OctopusCacheID is empty, but for the authenticated users it isn't possible.

Feature request:
Add a new directive fastcgi_cache_key_suffix
Construct the caching filename like this md5(fastcgi_cache_key) . '_' . fastcgi_cache_key_suffix

This will allow ngx_cache_purge to just issue a delete using a wildcard by executing:
del md5(fastcgi_cache_key)
del md5(fastcgi_cache_key) . '_*'

Or am I missing something?
Re: Finer grained control on caching
November 04, 2011 08:56AM
I had a closer look to the source of nginx, we probably need a variant for ngx_delete_file that supports wildcards
Re: Finer grained control on caching
November 07, 2011 04:33AM
This are getting more complicated since we're also caching by $device (detection done by nginx, based on UA) like this:

fastcgi_cache_key "$device$host$key_uri$cookie_OctopusCacheID" but now it's completely impossible to clear the cache for all 'devices'

If we could use (the yet to be implemented/accepted) fastcgi_cache_key_suffix we could rewrite it as:
fastcgi_cache_key_suffix $device$cookie_OctopusCacheID
fastcgi_cache_key "$host$key_uri"
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 139
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready