[Resolved] Bug with WP Cache

Status
Not open for further replies.

cool_recep

Well-Known Member
#1
I am logged into Wp-admin but I can not see the admin bar on top! This started after installing the Wp cache.
 
Last edited:

cool_recep

Well-Known Member
#4
Also, scheduled posts are not appearing on the front page anymore. They are published but they can not be seen on the front page...
 

NiteWave

Administrator
#5
I logged in wp-admin, top admin bar is there. waiting for further confirmation.

regarding "scheduled posts" issue, investigating it.
 

NiteWave

Administrator
#6
update:

1. admin top bar issue:
when access wp backend, /wp-admin/, top admin bar always there, not an issue.
after log in wp backend, even access front page, top admin bar should be there too. but in cool_recep 's case, top admin bar disappear and can see "x-litespeed-cache:hit" in response header.

per https://www.litespeedtech.com/support/wiki/doku.php/litespeed_wiki:cache:lscwp:installation
For vhosts configured through Apache httpd.conf, you may need to following Apache style configuration directive in .htaccess to enable cache lookup.

<IfModule LiteSpeed>
CacheLookup public on
</IfModule>
in cool_recep 's case, no such directive in .htaccess but it looks "CacheLookup public on" already set. so when admin user access the front page, get cached page which has no "top admin bar".

after adding
Code:
<IfModule LiteSpeed>
CacheLookup public off
</IfModule>
in .htaccess, when access front page, admin user get no-cached page which top admin bar is there.
change to
Code:
CacheLookup public on
then top admin bar disappear again.

i.e., can turn on/off the issue by set
Code:
CacheLookup public on/off
in .htaccess

2.scheduled posts issue
this is because after install "lscache for wordpress" plugin,
user never go
wp backend -> Settings -> LiteSpeed Cache -> General
and tick "Enable LiteSpeed Cache"
( URI: /wp-admin/options-general.php?page=litespeedcache)

only see this page
"LiteSpeed Cache Management" which has only 1 button "Purge All" there.
( URI: /wp-admin/admin.php?page=lscachemgr )

I have checked "Enable LiteSpeed Cache"
the issue should be gone.

note:
if "Enable LiteSpeed Cache" is not checked, plugin is disabled on wp side
but when access public wp site, readers may still be able to get cached page, refer issue "1. admin top bar issue"
 
Last edited by a moderator:

KevinFwu

Administrator
Staff member
#8
Hi cool_recep,

I found a solution for your scheduled posts issue. It will be uploaded in the next update.

Essentially, you will have a couple options, both of which involve WordPress' cron system:
1. No need to change anything, the front page will only update after someone accesses a page that hits the WordPress backend (after the post is supposed to be updated). If you have many visitors per day and if you are OK with an irregular update system, this may be the simplest option for you.

2. You will have to set up an actual cron job on your server, one that runs at a guaranteed interval. This will tell wordpress to run its cron job regularly.

In the future, we may add a feature to the web server to do the cron job for you, but it is not implemented at this time.

We will also have a wiki written explaining how to fix the issue, hopefully near the time the plug-in is updated.

Cheers,
Kevin
 

cool_recep

Well-Known Member
#9
Our web site gets 100K unique daily visitors. Every hour a post is released, somtimes with 30 min intervals. When a scheduled post does not appear, we lose potential hit. And I have to spend time to get into admin panel as the top bar still does not show up.

So, I need your solution as quick as possible. I really do not want to disable the plugin since it makes the site way faster.

Thanks.

Update: Solved admin bar issue with the htaccess setting provided above.
 
Last edited:

KevinFwu

Administrator
Staff member
#10
Hi cool_recep,

First, to ensure that it is updated, create a cron job that hits wp-cron.php often.

For Example,
Code:
*/1 * * * * wget -q -O /dev/null http://example.com/wordpress/wp-cron.php

To patch your current installation,

open wp-content/plugins/litespeed-cache/includes/class-litespeed-cache.php

Replace the following lines:
Code:
    private function load_public()
    {
        // user is not logged in
        add_action('wp', array($this, 'check_cacheable'), 5);
    }
with
Code:
    private function load_public()
    {
        // user is not logged in
        add_action('wp', array($this, 'check_cacheable'), 5);
        $purge_post_events = array(
            'edit_post',
            'save_post',
            'deleted_post',
            'trashed_post',
            'delete_attachment',
        );
        foreach ($purge_post_events as $event) {
            add_action( $event, array($this, 'purge_post'), 10, 2 );
        }

    }
And it should be updating per your cron job.

Let me know how it works,
Kevin
 

cool_recep

Well-Known Member
#11
Will do and let you know tomorrow. Thanks.

I have updated the plugin to 1.0.1. Do I setill need to set a cron job ?
 
Last edited:

KevinFwu

Administrator
Staff member
#12
Hi cool_recep,

The purpose of the cron job is to have the cron jobs activate reliably. If you think your site will hit the back end often enough (lots of logged in users visiting the page, etc.), no cron job should be necessary.

For your purposes, it might be a good idea to have a cron job just in case nobody hits the backend right after the post should have been published.

Kevin
 

cool_recep

Well-Known Member
#13
Now things are not really bright at the moment. I can not change the TTL settings since I get an out of memory error after the last update. And I also get logged out all the time...

And I still have to set the CacheLookup public setting to off!
 

KevinFwu

Administrator
Staff member
#14
Re: your memory issue,
In the wp-content/plugins/litespeed-cache/admin/class-litespeed-cache-admin.php file,
there is a line that says:
Code:
. $this->show_settings_excludes($options) .
There are many similar lines next to it, I'm only interested in the one that has "excludes" in it.
Change that line to just
Code:
.
and try accessing the cache settings again. This will cause the settings to not load the "Do Not Cache" tab contents. I suspect that tab is causing some issues.

If you'd rather not change any more code, we plan on releasing 1.0.2 soonish to fix that problem.

Re: your log out & CacheLookup issues,
Part of the fix for the admin bar is to not cache the page for logged in users. In the update, we added a cookie that tells the server that the browser client is logged in, so it should not see a cached page.

When you check a page, could you check to see if your request cookies includes one that says _lscache_vary = 1?

Also, could you try purging the cache? Perhaps the page wasn't updated since the code change.
 

cool_recep

Well-Known Member
#15
Now I was able to see the settings but I cloud not update the TTL as I got out of memory error, again...

Code:
Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 72 bytes) in /home/technopa/public_html/wp-includes/taxonomy.php on line 1857
 

KevinFwu

Administrator
Staff member
#17
Re TTL:
In the same file, wp-content/plugins/litespeed-cache/admin/class-litespeed-cache-admin.php
Delete the following code block. It is in validate_plugin_settings, or starts ~line 196:
Code:
        $cats = get_terms('category', 'hide_empty=0');
        $id = LiteSpeed_Cache_Config::OPID_EXCLUDES_CAT;
        $options[$id] = '';
        foreach ( $cats as $cat ) {
            $cat_name = $cat->name;
            $input_name = 'excat_' . $cat_name ;
            if ( isset($input[$input_name]) && ($cat_name === $input[$input_name]) ) {
                if (!empty($options[$id])) {
                    $options[$id] .= '.' ;
                }
                $options[$id] .= $cat->term_id ;
            }
        }

        $tags = get_terms('post_tag', 'hide_empty=0');
        $id = LiteSpeed_Cache_Config::OPID_EXCLUDES_TAG;
        $options[$id] = '';
        foreach ( $tags as $tag ) {
            $tag_name = $tag->name;
            $input_name = 'extag_' . $tag_name ;
            if ( isset($input[$input_name]) && ($tag_name === $input[$input_name]) ) {
                if (!empty($options[$id])) {
                    $options[$id] .= '.' ;
                }
                $options[$id] .= $tag->term_id ;
            }
        }
Re admin bar, could you pm me the link to your wordpress site, and a temporary user/pass that can log into the blog? Does not have to be an admin, I just want to confirm that the cookie is set when I log in, and if not, the headers that are set.
 

mistwang

LiteSpeed Staff
#19
We found that it is caused by a conflict of the same lscache cookie used for both xenforo and wordpress plugins.
You will have this problem when both plugin are enabled, we will try to fix it later.
For now, you can use one plugin without problem, if you do not care too much about the login bar on top, you can use both.
 

cool_recep

Well-Known Member
#20
Until a fix comes, I will just turn off CacheLookup public setting. And after all that bug reporting, I would welcome a mention of our website technopat.net in the next release's version history :)
 
Status
Not open for further replies.
Top