postmatic / postmatic-social

Lightweight social commenting for WordPress
GNU General Public License v2.0
5 stars 3 forks source link

Incompatible with nginx fastcgi_cache #53

Open mundschenk-at opened 8 years ago

mundschenk-at commented 8 years ago

Unfortunately, the plugin is currently incompatible with nginx' fastcgi_cache. When the plugin is enabled, the cache is never hit (most likely due to the session cookie set in every response header, even when a page does not contain a comment form).

Vernal commented 8 years ago

Hey @mundschenk-at when did you discover this and how can we reproduce? Can you give me more data?

mundschenk-at commented 8 years ago

I've set up a fastcgi_cache for our multisite network so that non-logged in users get a response directly from nginx instead of PHP. A few days ago, I noticed that the time-to-first-byte for my main blog was way too high for them to come from the cache. I added a caching indicator to the header, and indeed, every request was a cache miss (not bypass!). I also noted that Postmatic Social set a session cookie in that header (even for the start page, which does not contain a comment form!).

When I disabled Postmatic Social, the cache was hit normally again. I've not delved too deeply into the fastcgi_cache module, but I think by default it adds the cookies to the cache key, resulting in a miss all the time if the session cookie is not the same.

Vernal commented 8 years ago

@filkaris do you want to start by looking into PMS setting cookies when it should not... and then, if it's a good fit, look into fastcg_cache compatibility?

Vernal commented 8 years ago

Note from a user this weekend... could be a good lead:

It looks like Postmatic Social Login sets a cookie on every page load even if the plugin is not configured yet.

On some hosts using Varnish and the like, cookie activity like this will always cause a cache miss, rendering the server caching useless. Flywheel in particular has this reaction to plugins that behave this way.

Vernal commented 8 years ago

Hey @cyberhobo do you have any thoughts on this?

cyberhobo commented 8 years ago

I can verify the behavior and identify the code setting the cookie:

https://github.com/postmatic/postmatic-social/blob/master/functions/Postmatic_Social_Comments_Session.php#L28

Unfortunately that session is made global which might make it a bit of a job to figure out everywhere it's used and how it can be refactored.

Vernal commented 8 years ago

Ok let's push this to 1.2. Assigning to @filkaris for him to poke at.

mundschenk-at commented 7 years ago

Any news on this? I'd like to use the plugin, but with this bug in place, I can't.