cache requests with cookies
"cache requests with cookies"-settings that if there is a cookie with no value (eg. set by a third party app like intercom), the settings will be ignored and cause a MISS cache.
It remained unclear what feature is expected, for that reason we must decline the request.
-- PD
-
Daniel Kudwien commented
We are still re-applying this patch to all of our Plesk servers.
-
Daniel Kudwien commented
More background: The setting "Cache requests with cookies" does not ignore a cookie if it does not have non-empty value. This causes all such requests to hit the backend, which in turn can cause a server downtime due to overload.
The setting is supposed to not trigger a Nginx Cache bypass for the cookies that are named in the text box. So when a request contains that cookie, it is not supposed to hit the backend, but it does.
This is a straight bug; I don't know why Plesk classified it as "expected behavior" or feature. 🤷♂️
A temporary workaround is to set up cronjob for user root, which monkey-patches the default configuration file using the following command:
sed -i -e 's/\[\^\;\]+/\[\^\;\]\*/;' /usr/local/psa/admin/conf/templates/default/domain/service/nginxCache.php
The proper fix for Plesk's Nginx Cache default template is this:
```
diff --git a/usr/local/psa/admin/conf/templates/default/domain/service/nginxCache.php b/usr/local/psa/admin/conf/templates/default/domain/service/nginxCache.php
index 4340b1e..1abca39 100644
--- a/usr/local/psa/admin/conf/templates/default/domain/service/nginxCache.php
+++ b/usr/local/psa/admin/conf/templates/default/domain/service/nginxCache.php
@@ -16,7 +16,7 @@
set $cachecookie $httpcookie;
<?php foreach ($VAR->domain->physicalHosting->proxySettings['nginxCacheCookies'] as $cookie): ?>
- if ($cachecookie ~ "(.)(?:^|;)\s<?=pregquote($cookie)?>=[^;]+(?:$|;)(.*)") {
+ if ($cachecookie ~ "(.)(?:^|;)\s<?=pregquote($cookie)?>=[^;](?:$|;)(.)") {
set $cache_cookie $1$2;
}
<?php endforeach ?>
```