• Resolved rapsli

    (@rapsli)


    I’m hosting the site on WordPress.com. unfortunately we have noticed that with classified listing enabled, page Cache does not work. This makes the site slow to respond. This is for unauthenticated users!

    are you aware of this? If so, is there a fix for this?

    raphael

Viewing 12 replies - 1 through 12 (of 12 total)
  • Thread Starter rapsli

    (@rapsli)

    I could narrow this down a bit more. The problem is, the cookie that is said wp_rtcl_session. I would need a way to deactivate this.

    Plugin Support Ali Akbar Reyad

    (@alireyad)

    Hi,
    Which notice there shows? Actually what error shows there for wp_rtcl_session cookie key? Could you provide any screenshot? wp_rtcl_session deactivate means you want to remove the cookie key?

    Thank you

    Thread Starter rapsli

    (@rapsli)

    Hi. Well there is no error. It’s just that when wp_rtcl_session cookie is set, edge cache will be by passed. When I remove that session it will get a cache hit.

    I have removed the function setcookie() in SessionHandler.php, that makes that I get a Cache hit on every page, but unfortunately that leads to a user not being able to loggin anymore.

    Plugin Support Ali Akbar Reyad

    (@alireyad)

    Hi,
    Yes, we are using wp_rtcl_session key for different purpose as like as listing compare, checkout payment with WooCommerce. If you want to remove the cookie then these functionalities will not work.

    However, you can remove the line from this location app/Controllers/SessionHandler.php
    Line: 87 and let me know is it working or not for you.

    Thank you

    Thread Starter rapsli

    (@rapsli)

    Hi

    Yes I understand. I couldn’t completely remove it, else login didn’t work anymore. Any chance to get some kind of code into the plugin to make it a setting? for people who don’t need the payment option and only set the cookie when logging in.

    Plugin Support Ali Akbar Reyad

    (@alireyad)

    Hi,
    Yes, that line for logged out user. You can comment/remove the line right now then check cache issue. If it works properly then we will manage it from plugin in next update.

    Thank you

    Thread Starter rapsli

    (@rapsli)

    I have added to functions: is_login_attempt() and is_my_account_page() and then prevented the cookie to be set if either of these functions return true:

    public function init() {

    ? ? ? ? $cookie = $this->get_session_cookie();

    ? ? ? ? if ( $cookie ) {

    ? ? ? ? ? ? $this->_customer_id ? ? ? ?= $cookie[0];

    ? ? ? ? ? ? $this->_session_expiration = $cookie[1];

    ? ? ? ? ? ? $this->_session_expiring ? = $cookie[2];

    ? ? ? ? ? ? $this->_has_cookie ? ? ? ? = true;

    ? ? ? ? ? ? $this->_data ? ? ? ? ? ? ? = $this->get_session_data();

    ? ? ? ? ? ? // If the user logs in, update session.

    ? ? ? ? ? ? if ( is_user_logged_in() && strval( get_current_user_id() ) !== $this->_customer_id ) {

    ? ? ? ? ? ? ? ? $guest_session_id ? = $this->_customer_id;

    ? ? ? ? ? ? ? ? $this->_customer_id = strval( get_current_user_id() );

    ? ? ? ? ? ? ? ? $this->_dirty ? ? ? = true;

    ? ? ? ? ? ? ? ? $this->save_data( $guest_session_id );

    ? ? ? ? ? ? ? ? $this->set_customer_session_cookie( true );

    ? ? ? ? ? ? }

    ? ? ? ? ? ? // Update session if its close to expiring.

    ? ? ? ? ? ? if ( time() > $this->_session_expiring ) {

    ? ? ? ? ? ? ? ? $this->set_session_expiration();

    ? ? ? ? ? ? ? ? $this->update_session_timestamp( $this->_customer_id, $this->_session_expiration );

    ? ? ? ? ? ? }

    ? ? ? ? } else {

    ? ? ? ? ? ? $this->set_session_expiration();

    ? ? ? ? ? ? $this->_customer_id = $this->generate_customer_id();

    ? ? ? ? ? ? $this->_data ? ? ? ?= $this->get_session_data();

    ? ? ? ? ? ? if ( ! is_user_logged_in() ) {

    ? ? ? ? ? ? ? ? // Only set session cookie if on my-account page or login attempt

    ? ? ? ? ? ? ? ? if ($this->is_login_attempt() || $this->is_my_account_page()) {

    ? ? ? ? ? ? ? ? ? ? $this->set_customer_session_cookie( true );

    ? ? ? ? ? ? ? ? }

    ? ? ? ? ? ? }

    ? ? ? ? }

    ? ? ? ? //add_action( 'rtcl_set_cart_cookies', array( $this, 'set_customer_session_cookie' ), 10 ); // TODO :

    ? ? ? ? add_action( 'shutdown', [ $this, 'save_data' ], 20 );

    ? ? ? ? add_action( 'wp_logout', [ $this, 'destroy_session' ] );

    ? ? ? ? if ( ! is_user_logged_in() ) {

    ? ? ? ? ? ? add_filter( 'nonce_user_logged_out', [ $this, 'nonce_user_logged_out' ] );

    ? ? ? ? }

    ? ? }

    ? ? /**

    ? ? ?* Check if the current page is the my-account page.

    ? ? ?*

    ? ? ?* @return bool

    ? ? ?*/

    ? ? private function is_my_account_page() {

    ? ? ? ? // Check if the function exists

    ? ? ? ? if (!function_exists('is_page')) {

    ? ? ? ? ? ? return false;

    ? ? ? ? }

    ? ? ? ? // Check by page slug

    ? ? ? ? if (is_page('my-account')) {

    ? ? ? ? ? ? return true;

    ? ? ? ? }

    ? ? ? ? // Fallback: Check by page ID (replace 123 with your actual my-account page ID)

    ? ? ? ? if (is_page(6487)) {

    ? ? ? ? ? ? return true;

    ? ? ? ? }

    ? ? ? ? return false;

    ? ? }

    ? ? /**

    ? ? ?* Check if there is a login attempt.

    ? ? ?*

    ? ? ?* @return bool

    ? ? ?*/

    ? ? private function is_login_attempt() {

    ? ? ? ? return isset($_POST['log']) && isset($_POST['pwd']);

    ? ? }
    Plugin Support Ali Akbar Reyad

    (@alireyad)

    Hi,
    What about my suggested line? that does not work?

    Thread Starter rapsli

    (@rapsli)

    it works, but then login breaks. That’s why I put the is_login_attempt() there.

    Plugin Support Ali Akbar Reyad

    (@alireyad)

    Hi,
    We added hook for it where you changed code. Now you can do same thing using filter hook from child theme.

    Thank you

    Thread Starter rapsli

    (@rapsli)

    great. Could you mention the hook here, maybe it will also be helpful for others.

    Plugin Support Ali Akbar Reyad

    (@alireyad)

    Hi,
    You can use following filter hook –

    apply_filters('wp_rtcl_session_allow_guest_user', true)

    Thank you

Viewing 12 replies - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.