Articles in this section

Plesk nginx caching doesn't cache pages with cookies

Plesk for Linux kb: technical ABT: Group A

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.

  1. Log in to Plesk
  2. Go to Domains > example.com > Apache & nginx
  3. Enter the required cookies in the field Cache requests with cookies

    For example, if _ga and _gid cookie names are set, nginx will only cache HTTP requests with cookie headers that contain _ga or _gid.

    79199.png

Was this article helpful?

Comments

1 comment
Date Votes
  • 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 HIT
    Cookie: _ga= → BYPASS

    We observed the same pattern with allowed Complianz cookies, including cmplz_functional and cmplz_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

    0

Please sign in to leave a comment.