Topic on Project:Support desk

Extension:CategoryTree Not Updating with Cache Enabled

6
Johnywhy (talkcontribs)

Not finding a solution here.

i've tried purging the page with Extension:Purge, and re-entering the source. Neither makes the tree update.

I'm able to get refresh by turning off caching, and then re-enter the page-source:

$wgEnableParserCache = false; 
$wgCachePages = false;

However, won't the site performance suffer without caching?

Johnywhy (talkcontribs)

Update: Making a little progress. The following settings are in my LocalSettings.php:

# not sure why tree is not refreshing, if set to NONE! Was default:
$wgMainCacheType = CACHE_NONE;
$wgMemCachedServers = [];

# unclear why this is commented by default
# $wgCacheDirectory = "$IP/cache";

# i installed this
require_once "$IP/extensions/MagicNoCache/MagicNoCache.php";

# i added this to ensure caching. 
$wgEnableParserCache = true; 
$wgCachePages = true;

Then i added the magic word __NOCACHE__ to the page containing the Tree.

I notice that, with above setting, new pages are added to the Tree, but old copy of moved pages stays in Tree! I'm guessing that might be intended as a convenience (?), but without redirect it's just a dead link.

We don't want deleted pages to stay in Tree.

Update: Changed $wgMainCacheType to ANYTHING. Now seeing improved performance on pages, but no change in Tree behavior-- deleted pages still showing.

Ciencia Al Poder (talkcontribs)
Bawolff (talkcontribs)

Just set $wgCategoryTreeDisableCache = true;

This will cause the parser cache to be disabled on all pages that use categorytree (You can still potentially have browser cache or file cache (if you enable file cache, its not on by default) giving stale results, but that's much less likely).

Johnywhy (talkcontribs)

i set $wgCategoryTreeDisableCache = true;

A little progress:

Tree is no longer showing deleted pages.

But tree is not showing moved pages. The old version of the moved page is in the tree, not the new version. (i moved the page to a different namespace).

API and Special:CategoryTree shows the page (Peaches) has been moved to new namespace (Main) from previous namespace (Draft):

https://gunretort.xyz/index.php/Special:CategoryTree?target=Category%3ADefinitions&mode=all

However, Tree shows the page still in it's old namespace (Draft):

https://gunretort.xyz/index.php/Portal:Table_of_Contents

Urfiner (talkcontribs)

There is another place for caching: https://phabricator.wikimedia.org/T35608


We can do something stupid like turn off Ajax if $wgCategoryTreeDisableCache == true. That will work only for newly created pages. If you want a better fix you can skip all cache operations for the case cache is turned off.


extensions/CategoryTree/includes/ApiCategoryTree.php

private function getHTML( $ct, $title, $depth, $ctConfig ) {
	global $wgContLang, $wgMemc;
	//Added global cache
	global wgCategoryTreeDisableCache;

	$mckey = wfMemcKey(
			'ajax-categorytree',
			md5( $title->getDBkey() ),
			md5( $ct->getOptionsAsCacheKey( $depth ) ),
			$this->getLanguage()->getCode(),
			$wgContLang->getExtraHashOptions(),
			$ctConfig->get( 'RenderHashAppend' )
	);

	$touched = $this->getConditionalRequestData( 'last-modified' );
	if ( $touched ) {
			$mcvalue = $wgMemc->get( $mckey );
			if ( $mcvalue && $touched <= $mcvalue['timestamp'] ) {
					$html = $mcvalue['value'];
			}
	}

	if ( !isset( $html ) ) {
			$html = $ct->renderChildren( $title, $depth );

			//Skip cache update if $wgCategoryTreeDisableCache == true
			if( $wgCategoryTreeDisableCache != true ){
					$wgMemc->set(
							$mckey,
							[
									'timestamp' => wfTimestampNow(),
									'value' => $html
							],
							86400
					);
			}
	}
	return trim( $html );
}
Reply to "Extension:CategoryTree Not Updating with Cache Enabled"