Symptoms
When Nginx caching is enabled with Plesk's default settings, all pages with a cookie (even _gid
only) is not be cached by default.
Cause
That is the expected behavior.
According to Plesk documentation:
PLESK_INFO: By default, nginx does not cache HTTP requests that contain the Cookie HTTP header. You can change this behavior and have nginx cache HTTP requests containing certain cookies by specifying the names of the cookies in the “Cache requests with cookies” field.
The caching for pages using cookies and/or user-specified parameters should be configured very carefully since it may compromise website security or lead to incorrect behavior of a web application, that is why this feature is disabled by default. The same logic applies to the default Nginx behavior as per Nginx documentation:
PLESK_INFO: It does not cache responses with ... Set-Cookie in the response header. You can override these defaults as described in the answers below.
Resolution
This behavior can be changed to make Nginx cache HTTP requests containing certain cookies by specifying the names of the cookies in the Cache requests with cookies field:
-
Go to Domains > example.com > Apache and Nginx Settings.
-
Specify required cookie names in the Cache requests with cookies field.
For example, _ga
and _gid
cookie names are specified, Nginx will only cache HTTP requests with cookie headers that contain _ga
or _gid
.
Note: Nginx will not cache HTTP requests with cookie headers containing at least one cookie name that is not specified in the field.
Comments
0 comments
Please sign in to leave a comment.