Applicable to:
- Plesk for Linux
Symptoms
Plesk pages with cookies aren't cached by nginx caching, with this in the page's headers: x-cache-status: BYPASS
Cause
nginx doesn't cache requests that have a Cookie HTTP header by default. Caching for pages that use cookies or user-specified parameters should be configured with great care, as improper setup can compromise website security or cause incorrect behavior in a web application. This feature is therefore disabled by default. The same principle applies to the default behavior of nginx, as outlined in its documentation.
Resolution
To change this behavior, configure the domain to cache pages with cookies in the nginx settings.
- Log in to Plesk
- Go to Domains > example.com > Apache & nginx
-
Enter the required cookies in the field Cache requests with cookies
For example, if
_gaand_gidcookie names are set, nginx will only cache HTTP requests with cookie headers that contain_gaor_gid.
Comments
Hello,
I have already added the relevant cookie names under “Cache requests with cookies” in Plesk Obsidian 18.0.81.
However, GET requests to the same public WordPress page show different results depending on whether the allowed cookie has a value.
Cookie: _ga=test→ MISS or HITCookie: _ga=→ BYPASSWe observed the same pattern with allowed Complianz cookies, including
cmplz_functionalandcmplz_consented_services.Is this expected behavior? Should explicitly allowed cookies also permit caching when their values are empty?
Could the generated cookie-matching expression require at least one character in the value? This is only a hypothesis, as I cannot access the active nginx configuration on my shared hosting account.
Please clarify
Please sign in to leave a comment.