Re:
https://www.hiawatha-webserver.org/forum/topic/1512I know this topic has come up before, but I thought I might try and figure at least some of it out on my own. For Drupal there are a couple of different ways of detecting if the cache needs to be bypassed.
Nginx uses the following configuration:
## Let Ajax calls go through.
map $uri $no_cache_ajax {
default 0;
/system/ajax 1;
}
## Testing for the session cookie being present. If there is then no
## caching is to be done.
map $http_cookie $no_cache_cookie {
default 0;
~SESS 1; # PHP session cookie
}
## Combine both results to get the cache bypassing mapping.
map $no_cache_ajax$no_cache_cookie $no_cache {
default 1;
00 0;
}
Looking at the URLToolkit options is looks like we should be able to leverage the Header and Match commands to achieve the above results. I have added another toolkit operation called "BypassCache" which sets a bypass cache flag in the session. Operations are stackable (flow is set to continue) so you can do multiple checks and still rewrite the URL.
Here is an example toolkit:
UrlToolkit {
ToolkitID = nocache
Match ^/nocache.php BypassCache
Header Cookie ^SESS BypassCache
}
Initial testing looks promising. I was able to get expected results with some limited testing using the Match operation but I didn't see what I was expecting with the Header operation. I may have my syntax wrong though so I will do additional testing as time allow.
Hope someone finds this useful!
And here is a link to the code on PasteBin:
http://pastebin.com/tw5zpMiv