speeding up whonix.org through caching

Website speed tests:

https://developers.google.com/speed/pagespeed/insights/


Already using mediawiki caching settings for a long time.

## Shared memory settings
$wgMainCacheType = CACHE_MEMCACHED;
$wgMessageCacheType = CACHE_MEMCACHED;
$wgUseLocalMessageCache = true;
$wgParserCacheType = CACHE_MEMCACHED;
$wgUseGzip = true;
$wgEnableSidebarCache = true;
$wgMemCachedServers = array("127.0.0.1:11211");
$wgexLingoCacheType = CACHE_MEMCACHED;
$wgLocalisationUpdateDirectory = "$IP/cache";
## Set $wgCacheDirectory to a writable directory on the web server
## to make your wiki go slightly faster. The directory should not
## be publically accessible from the web.
$wgCacheDirectory = "$IP/cache";
$wgParserCacheExpireTime = 2592000;
$wgResourceLoaderMaxage = 2592000;
$wgEnableSidebarCache = true;
#enable file cache - https://www.mediawiki.org/wiki/Manual:File_cache
$wgUseFileCache = true; /* default: false */
$wgFileCacheDirectory = "$IP/cache";
$wgShowIPinHeader = false;
$wgDisableCounters = true;
## If on, the sidebar navigation links are cached for users with the current language set. This can save a touch of load on a busy site by shaving off extra message lookups.
## However it is also fragile: changing the site configuration, or having a variable $wgArticlePath, can produce broken links that don't update as expected.
$wgEnableSidebarCache = true;
## testing this cache setting
$wgFileCacheDepth = 0;
#$wgUseSquid = true;
#$wgSquidServers = array( '127.0.0.1:6081' );
#$wgUsePrivateIPs = true;
#$wgSquidMaxage = 1800;
## maybe needed for Varnish but not using Varnish anymore
#$wgCacheEpoch = wfTimestamp( TS_MW, time() - 86400 ); # 60*60*24 = 1 day
$wgInvalidateCacheOnLocalSettingsChange = true;
$wgUseESI = true;
$wgUseETag = true;

This already makes use of memcached.


Can’t use a single nginx server to be a web server and cache (proxy_cache) at the same time. It wouldn’t make sense either. Linux is already caching files on the disk. See:

https://www.cachoid.com/blog/2017/03/28/nginx-server-cannot-memory-cache-files/


Using nginx fastcgi_cache together with mediawiki might make sense, but I always get cache MISS and cache isn’t populated. (Works for whonix.org/index.php but not needed since currently not using PHP.) No useful web search results. All information is years old.


discourse is quite slow. But does not look like a lot can be done.


CDN’s are probably not an option? Because a lot of them block Tor users. (And are USA companies.) And even if not blocking Tor, they’re a permanent “MITM”. It’s not clear if these would actually reduce security but it would probably be criticized.


Potential future enhancements:

https://www.nginx.com/blog/responsive-images-without-headaches-nginx-plus/

https://www.ngxpagespeed.com/

https://www.modpagespeed.com/doc/download

1 Like

Discourse is described as a JS app rather than a website with html/css so traditional caching methods like Varnish are useless.

Some suggestions were looking into optimizing the Redis database loads, disabling forced image loading, implementing lazy loading

1 Like

ngx_pagespeed was implemented.

?PageSpeedFilters=+debug
or
?PageSpeed=off
can be added anywhere. Examples:

1 Like

PageSpeed off is so much faster

1 Like

That’s strange. The effects might not be measurable when testing this over Tor since Tor adds too much random delay.


off:

https://gtmetrix.com/reports/www.whonix.org/m7zYnWl2#video first paint at 1.9 s.


on:

https://gtmetrix.com/reports/www.whonix.org/3GQu66qV#video at 1.4 s.

The Fully Loaded Time is higher but that is OK due to image lazy loading. More importantly the initial part the user wants to see is visible faster.


?PageSpeed=off
can be appended to any URL. Example:

ngx_pagespeed is currently active for whonix.org frontpage and wiki only. Phabricator untested and forums is said to not make sense.

This might require a neutral tester. https://gtmetrix.com looks cool and this for sure can use more testing / tuning. Also supports different server locations. And has a compare feature which I should use more.

Testing from London, UK (or any other EU location if there was any) makes more sense than lets say testing from USA or Canada. Otherwise we’re not really testing the server but random latency added by connecting oversee.

Just now created a comparison with these settings:

London, UK
Firefox (Desktop) 54.0.1
2G Mobile (240/200 Kbps, 400ms)
Options: Video

https://gtmetrix.com/compare/KyqBWd1Z/BFBJo6fh

6.5 seconds (on) vs 8.5 seconds (off) on a 2G connection according to gtmetrix.

However, I can imagine that there are scenarios where ngx_pagespeed actually reduces the website speed. Is there any website speed test tool that supports Tor and/or even onions?

1 Like

No site that i know of, but browser addons can be used as mentioned on SE.

Does nothing in Tor Browser at all except show ? for any speed measurement.

Any of the related addons on that page work for you?