0

I have setup nginx to cache page requests as described in this tutorial.

There for looged in users the caching is disabled in this tutorial by an if request as:

# Don't use the cache for cookied logged in users or recent commenters
if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in|woocommerce_cart_hash|woocommerce_items_in_cart") {
set $skip_cache 1;
}

Which works as expected. But if I open my site in a new private window and access a previously cached site (by another person, not me) – I also receive a “x-cache HIT” in the server response – so I assume that kokos-analythics, the plugin I use to get the amount of visitors, can’t set a cookie or count the correct amount of users? Does anybody have experience with this or can help me configuring the cache correctly?

Thanks

mathse

mathse
  • 3
  • 1

1 Answers1

0

If you are sending different content to different users, then you cannot use nginx caching.

In your case, your analytics plugin makes the content different for every visitor in terms of its cookie, which is part of content.

You should use an analytics system that doesn't require modifying pages sent to users if you want to use nginx caching.

Tero Kilkanen
  • 36,796
  • 3
  • 41
  • 63