• Hello I found, that when non logged-in user comes to the cached site, then logged in (membership website) and he want to add some posts to his favorited posts, on his favorited lists page there is nothing displayed.

    In console I see, that your plugin still saves posts ids into local storage for this logged-in user, so that means, that your plugin doesn’t recognize that he is logged in if website is cached.

    All pages which are only for logged-in user, including favorite lists page they are, of course, uncached. Other pages must be cached!!!

    And this applies to all sites in the world, not just my site. All web developers should take this into account when developing their applications.

    Your plugin is very promising and I want to use it very much, but if it doesn’t work properly on cached website, it si quite useless.

    Please can you fix it, so it works also when websites is cached.

    It will want something like “fallback for cached sites”.

    I use Rehub theme. They have their own feature for favorited posts. But they save posts ids for non logged users into transients and for concrete IP adress.

    So, when more than one person with the same IP address uses this feature (such as at home or in the same office), everyone will see the posts together on the favorites list page. And this is useless too!

    But In Rehub theme they use some code “fallback for cached sites”, and thanks to that, it also works on the cached website.

    I can provide you some peace of code for this “fallback for cached sites” for inspiration, for example, how they dealt with it.

    Thank you for your time and I hope you try to customize your plugin for cached sites.

    David

    • This topic was modified 3 years, 1 month ago by davidki.
Viewing 13 replies - 1 through 13 (of 13 total)
  • Thread Starter davidki

    (@davidki)

    Hello, I tested this “fallback for cached sites” function for favorited posts from Rehub theme once again and I was mistaken.

    It doesn’t work well too.

    So question is, if it is possible to make it work like, so when non logged-in user comes to the cached site, then logged in (membership website) and add some posts to his favorited posts. He will see favorited posts listed on favorited lists page.

    Plugin Author Takashi Matsuyama

    (@takashimatsuyama)

    Hello, @davidki
    Thank you for your rating and your question.

    What method do you use to cache your site?
    Is it a WordPress plugin? Or a web server?

    Caching is a difficult task for me because there are many ways to do it and the problem is not reproducible.

    Also, this plugin does not control the cache, so it does not provide any configuration features related to the cache.

    Can’t you select what to exclude in the program that controls the cache?
    For example, if there is a setting in the cache control that says “Do not serve cache to known users”, you could try that.

    Thanks

    Thread Starter davidki

    (@davidki)

    Hello,

    I use Wp fastest cache plugin for caching.

    I found that when I disable caching for logged-in user, favorited posts works as expected.

    But I need that website is cached also for logged user. I excluded a few pages from caching which are displayed only for logged users (including page with favoreted posts list), but all other pages have the same content for logged-in and for guest users and need to be cached.

    I found that in your plugin you use “wp_localize_script” and insert “1” into “user_logged_in” if is user logged in.

    It means if non logged-in user comes to the cached site (have empty value for “user_logged_in”), then logged in, because of cache, user have still empty value for “user_logged_in” in your script and your plugin saves posts ids into local storage for this logged-in user.

    I found that wordpress create “wordpress_logged_in” cookie everytime user log in even when the website is cached.

    So, if your plugin could check for existens of this cookie “wordpress_logged_in”, the favorited function can work even on cached pages for logged in user.

    I am not as eperienced programmer as you are, so I want to ask you, if you can help me implement in your plugin way, for checking of existens of cookie “wordpress_logged_in”. And if this cookie will be found, than the user meta will be used instead of local storage.

    Thank you, very much for your time, Takashi.

    Plugin Author Takashi Matsuyama

    (@takashimatsuyama)

    Hello, @davidki

    Unfortunately, I believe that “is_user_logged_in” is the standard way to determine login, so it is difficult to replace this plugin’s login determination with “wordpress_logged_in_{hash}” at this stage. Also, I think this change needs a lot of testing.
    I think it would be better to do it in the theme’s function.php or to bring it up in the “WP Fastest Cache” topic.
    I think this is a common topic for “WP Fastest Cache”.

    “WP Fastest Cache” topic might have a good solution.
    https://www.ads-software.com/support/plugin/wp-fastest-cache/

    Thanks

    Thread Starter davidki

    (@davidki)

    I discussed it with developer of WP Fastest Cache plugin and he wrote to me this about your plugin:

    ” the plugin is not compatible with the cached plugins. When a page is cached, the page is saved as a static html file so PHP does not work. The datas must be loaded via Ajax. ”

    It means that if you don’t want to use my solution with checking of cookie “wordpress_logged_in”, you should generate and update value of variable “user_logged_in” in your script you are adding by wp_localize_script() with Ajax. So that the value of “user_logged_in” is always updated.

    Can you to this, please?

    Plugin Author Takashi Matsuyama

    (@takashimatsuyama)

    Hello, @davidki
    Thank you for your valuable input.

    I will think about it and try to see if there is a way to make it work.
    I will post the result in this topic again.

    Thanks

    Plugin Author Takashi Matsuyama

    (@takashimatsuyama)

    Hello, @davidki

    I am testing the WP Fastest Cache plugin in a development environment, and the current version is working fine for me. So I can’t reproduce the same issue as you. is there another setting in the WP Fastest Cache plugin?

    However, maybe the following changes will help us make some progress.
    This change may affect the issues in this topic.
    If you are able to try it in a development environment, please let me know the result.

    That’s two points.

    /assets/list.js
    Add between lines 27 and 28 of /assets/list.js ( after “data_set[CCC.favorite.storage_key()]” and before “data_set[‘ccc-excerpt’]” )

    data_set['user_logged_in'] = CCC_MY_FAVORITE_UPDATE.user_logged_in;

    /assets/list.php
    Change line 11 in /assets/list.php

    if ( $_POST['user_logged_in'] == false ) {

    Thanks

    Thread Starter davidki

    (@davidki)

    Hello,
    thank you for your willingness to address this issue, because many people facing this problem with caching website with membership section.

    I tryed your plugin with changes in code in files “list.js” and “list.php” according to your suggestion.

    As I expected, It doesn’t work.

    I think you did not understand the problem correctly and how to test it properly.

    In WP Fastest Cache plugin it needs to be unchecked checkbox “Don’t show the cached version for desktop to mobile devices”. So the website is cached even for logged in users.

    The issue is about caching pages on a website that has a membership section.

    WP Fastest Cache plugin disable caching for website admin by default.

    So to test it properly, you need to use some membership plugin. Or some code which allows you tu logged in as website user (but not as admin).

    It is best to test it as follows:

    1. You as admin turn caching “ON” by enabling cache system in WP Fastest Cache plugin.

    2. Open another web browser (in which you are not logged in as admin) and visit page with posts which is possible to add in your favorited posts. By this the page was cached.

    3. Now go to login form and log as website user (not admin). After you logged in you can see in browser console html class “logged-in” in html <body> tag. (Page with login form need to be exclude from cache by addying rule in WP Fastest Cache plugin).

    4. Now as logged in user go on previously cached page with posts which is possible to add in your favorited posts and add some posts to your favorited posts.

    Because this page is cached, there will be no class “logged-in” in html <body> tag.

    In page code, the value of variable “user_logged_in” in your script you are adding by wp_localize_script() will be empty (should be “1” for logged in user!).

    Your plugin will add favorited posts in local storage instead of user meta for logged in user.

    And therefor the logged in user on membership website will not see any of his favorited posts on page with lists of favorited posts.

    When you log out, only now you will see favorited posts on page with lists of favorited posts. But these are the posts which you added in your favorited as logged in user!

    I hope, now you better understand, that your plugin is not possible to use on website with membership section, because using uncached website is unnecessarily large attack on the web server.

    So, please, once again try this:

    you should generate and update value of variable “user_logged_in” in your script you are adding by wp_localize_script() with Ajax. So that the value of “user_logged_in” is always updated.

    Thank you.

    Plugin Author Takashi Matsuyama

    (@takashimatsuyama)

    Hello, @davidki

    Thanks to your detailed explanation, I now understand the issue with this topic.
    I have tried with several cache plugins with the same result. They are WP Fastest Cache, W3 Total Cache and WP Super Cache.

    To get this plugin to work on a cached website, I had to add
    To make this plugin work on a cached website, you need to get “is_user_logged_in()” every time with “ajax” and also get “wp_create_nonce()” every time with “ajax”.
    In this plugin, there are three types of this nonce, and they are used in various places apart from the login decision.

    For cached sites, “is_user_logged_in()” and “wp_create_nonce()” by “wp_localize_script()” are not necessary because they are meaningless.
    Therefore, we need to rethink the underlying design to make them work. Also, there will probably be an impact on performance due to increased communication.

    I changed the code based on these factors, and it seems to be working with cached websites, probably in my environment. However, I have not verified it from various perspectives and the code is just to accomplish the task of this topic. There is a good chance that this change will cause other bugs.

    Therefore, I cannot yet merge the changes of this issue into the official www.ads-software.com directory, but I would like to clone it for future use and verify it carefully in another repository as I review the specification.

    If you want to test this code, please do so in a test environment. It may cause bugs and various problems.
    A known problem is that the appearance of “Read more” in the list is unstable.

    https://github.com/takashi-matsuyama/my-favorites-cached-beta

    Thanks to you for giving me a good opportunity.

    Thread Starter davidki

    (@davidki)

    Hello Takashi,

    I tested your beta plugin for cached websites and finally it works like it should on cached sites for logged in member.

    I didn’t find any problem or errors except bad functioning of load more button.

    This is the problem about which I wrote you before.

    When I delete all posts from list using delete all button, everything work well.

    But when I delete posts one by one, after the post count display “0”, after a while some posts display again without page reload.

    The faster I delete posts one by one, the more they are displayed again. Even If I deleted they before.

    I increased timeout for “3000”, but it doesn’t solve the problem.

    Plugin Author Takashi Matsuyama

    (@takashimatsuyama)

    Hello, @davidki

    Thank you for testing the operation.

    Since asynchronous communication overlaps in this part, the timing of acquisition seems to differ depending on the user’s communication environment.

    I will look for a good solution, including the part you pointed out.

    It may take some time, I will post progress on this topic again.

    Thanks

    Thread Starter davidki

    (@davidki)

    Hello, Takashi.

    Any progress with this problem?

    Thank you.

    Plugin Author Takashi Matsuyama

    (@takashimatsuyama)

    Hello, @davidki .

    Thank you for your question.
    Sorry for the delay in answering.

    However, I’m sorry. I have not resolved the issue yet.

    I am very busy at work right now and it is difficult to organize the timing of multiple Ajax.

    Therefore, the problem of Ajax time difference retrieved from the database is currently being addressed by “window.location.reload()”.

    Reference Topic

    Thanks

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Plugin doesn’t work on cached site properly’ is closed to new replies.