wp-rocket icon indicating copy to clipboard operation
wp-rocket copied to clipboard

Same cache for loggedin and guest users

Open grosssmutttr opened this issue 5 years ago • 25 comments

Hi there,

we ran a large WooCommerce shopping site and are very satisfied with the functionalities WP Rocket comes with.

Unfortunately there is no option to tell WP-Rocket that it should use the same cache for loggedin and guest users.

So we don't want to create separate cache files for loggedin users as you already can - we just want to tell WP Rocket to use the same cache files (that are preloaded) for guest and loggedin users. As WP Rocket correctly excludes the pages of WooCommerce that should not be cached this should work great and give some big advantages.

One must be careful, if the theme for example uses a static cart number to show the current number of items in the cart - so that number must be fetched via ajax - but except that it would perfectly fit our needs and I also think that this would be a great feature for other users.

So my idea is to have an option in the backend to trigger whether the same cache files should be used for loggedin and guest users - if this checkbox is checked another checkbox opens up with "exclude Administrators" from getting cached pages - so Administrators can still watch the Shop without cache.

I already tried the available plugins from here https://docs.wp-rocket.me/article/313-user-cache and https://docs.wp-rocket.me/article/919-disable-cache-for-logged-in-administrators But as said above - there is always a separate cache for loggedin and guest user,

grosssmutttr avatar Sep 30 '19 10:09 grosssmutttr

A related ticket: https://secure.helpscout.net/conversation/1048787806/139666/

vmanthos avatar Jan 07 '20 07:01 vmanthos

Another one: https://secure.helpscout.net/conversation/1151886362/161965?folderId=2135277

vmanthos avatar May 04 '20 04:05 vmanthos

Another related ticket: https://secure.helpscout.net/conversation/1392141179/230154/

adinaWP avatar Jan 11 '21 12:01 adinaWP

@vmanthos @Tabrisrp Can this be done by using a helper plugin?

GeekPress avatar Feb 10 '21 14:02 GeekPress

@GeekPress This cannot be done using a helper plugin, as far as I understand.

Currently, we don't have a filter that we could use to do that, the way we have for the common cache for logged in users: https://github.com/wp-media/wp-rocket/blob/40ecc6c70de1995295a1994fb77a6ecb93885287/inc/functions/files.php#L78

That's used in the Cache class to determine the path of the cached file we'll serve: https://github.com/wp-media/wp-rocket/blob/355071c41725f399b0075cc9df5419aeb25cc3f3/inc/classes/Buffer/class-cache.php#L530

vmanthos avatar Feb 11 '21 07:02 vmanthos

+1

Having the option to have a common cache for logged in visitors would be a great (for a WooCommerce site). There's simply no practical advantage of having a separate cache for each logged in user. In that scenario, pages are only cached when a user is logged in, so every page will take even longer time to load.. By the time the same user logged in and by chance visited the same product page, cache would be expired. Also not good for resources - having cache for 100s/1000s users for 100s of products would create a high server load and take a lot of space.

"Common Cache For Logged-in Users" wouldn't work in either, because if a shop manager is logged in before a random visitor, the visitor would then see shop managers (or admin's) cached version, so this approach is fundamentally flawed.

I think using the "public cache" for logged in user would be the best way forward. Swift Performance plugin has already implemented this feature successfully.

alpertheidiot avatar Mar 02 '21 00:03 alpertheidiot

related: https://secure.helpscout.net/conversation/1478567372/254576?folderId=3864740

NataliaDrause avatar Apr 13 '21 13:04 NataliaDrause

Hello. Is there any recent update? I have a WooCommerce store and find WP Rocket useful, but if you cannot preload the product pages for logged-in users (customers), I might have to switch to another caching plugin unfortunately...

phil00907 avatar Aug 09 '21 14:08 phil00907

Related request: https://secure.helpscout.net/conversation/1568992555/278868/

NataliaDrause avatar Aug 15 '21 09:08 NataliaDrause

Another request https://secure.helpscout.net/conversation/1898866009/345291/

camilamadronero-zz avatar May 27 '22 21:05 camilamadronero-zz

I have solved this issue by editing the advanced-cache.php file and injecting a custom Cache instance. This custom implementation removes the -loggedin-<random_hash> from the cache file path. This way, everyone always gets served the guest cache files.

I have made this into a small helper plugin over here.

sanderdekroon avatar Jul 08 '22 13:07 sanderdekroon

I made a simple snippet to make good use of the User Cache. Hope this can help you.

https://github.com/dgnerlab/unbreakable-user-permalink

dgnerlab avatar Aug 28 '22 11:08 dgnerlab

Related request: https://secure.helpscout.net/conversation/2018545345/370625/

camilamadronero-zz avatar Sep 26 '22 22:09 camilamadronero-zz

Related https://secure.helpscout.net/conversation/2003655862/367291/

camilamadronero-zz avatar Sep 26 '22 22:09 camilamadronero-zz

Related: https://secure.helpscout.net/conversation/2063772281/380725/

joejoe04 avatar Nov 10 '22 21:11 joejoe04

Related: https://secure.helpscout.net/conversation/2066501274/381299?folderId=1213662

WordPresseur avatar Nov 16 '22 14:11 WordPresseur

How can this not be addressed? If you have a very basic shop with absolutely no user content shown for logged-in users the guest cache should be sufficient for loggedin users, right?

Currently loggedin users on such sites just have a bad experience because the cache has to be build every time for the user which results to the exact same cached version as for the guest users.

cape-dev avatar Mar 22 '23 12:03 cape-dev

4 years and still no solution to this?

grosssmutttr avatar Oct 31 '23 11:10 grosssmutttr

@piotrbak Any update on this? On any large ecommerce store this is a problem - The uncached pages are too slow for general use on a particular site. Just trying to speed things up for my clients.

Related: https://secure.helpscout.net/conversation/2402778568/450786/

mviniciosbarreto avatar Nov 09 '23 18:11 mviniciosbarreto

I just discovered the unviability of WP Rocket on large stores. I was creating a gameplan to take action

  • Switch cart count to ajax with cacheable fragments (great)
  • Disable automatic purging in WP Rocket, as products/categories were not cached - maybe for a few minutes. Users visiting the same pages created mutliple cache requests, which lead to WP Rocket causing a queue, just for it to delete the cached data 1 minute later.
  • Cache logged in users. This is where I hit a brickwall. Not delivering the public cache to logged in users is not ideal. If you know what you're doing, the public cache would be super efficient to use instead.

Unfortuently i'd cancelled my license due to WP Rocket not being a great fit for high traffic WooCommerce stores

hagedigital avatar Jan 23 '24 05:01 hagedigital

I solved the problem using nginx-rocket configuration.

At the nginx file default.conf, just commented the following lines:

" if ($http_cookie ~* "(wordpress_logged_in_|wp-postpass_|woocommerce_items_in_cart|woocommerce_cart_hash|wptouch_switch_toogle|comment_author_|comment_author_email_)") #{ set $rocket_bypass 0; set $rocket_is_bypassed "BYPASS"; set $rocket_reason "Cookie"; } "

During several months I have been running a shop store using one only cache to all users, logged-in and guests with relevant advantages in terms of performance.

However, with the wp-rocket release 3.16, the system its using separate mobile and desktop cache files.

Its great for optimization. However, since nginx-rocket does not fully work with separate mobile cache, you only need to disable mobile cache or adjust nginx-rocket config.

PauloOF avatar May 12 '24 15:05 PauloOF

We could really use this feature - First requested almost 5 years ago?

The issue here is on huge or memory intensive sites where caching is required - It makes editing painful because the uncached version is extremely slow. This wont suit every site but it will massively benefit extremely large sites where editing speed suffers due to memory intensive processes and db lookups.

Please can we have an official update on this issue? I can see no one from WP-Rocket is assigned or checking this issue.

Related: https://secure.helpscout.net/conversation/2595496756/491116

suzoutlet avatar May 13 '24 11:05 suzoutlet

Related: https://secure.helpscout.net/conversation/2595496756/491116

Thats not really helping, we can't see the conversation.

Stibo avatar May 13 '24 11:05 Stibo

Another request: https://secure.helpscout.net/conversation/2601731785/492300/

mifrero avatar May 21 '24 11:05 mifrero

Can someone please explain - Is helpscout an official WP-Rocket forum? If the answer is no - why are users reporting WP-Rocket issues on help scout and not reporting them here on the official github?

We are desperate for this feature - We have sites with extremely complex variable products where uncached has a stupendously long load time. By adding this feature it not only reduces php memory usage used by admins because requests made are cached like visitors and also improves the scalability of WP-Rocket as a viable caching solution as a site grows.