TNG Cache Statistics Page Mod

Post Reply
steven
Posts: 133
Joined: Sun Oct 01, 2017 3:08 pm

TNG Cache Statistics Page Mod

Post by steven »

Everyone tries to improve speed and access to their website. However, given the nature of TNG's dynamic pages, speeding up this process is more difficult. I've found TNG statistics page is an exception as the page only changes when content is added and is not dependent on the user logging in or their status.

The statistics page takes a while to load on my site because there are a lot of people and media files. I decided to cache the statistics page so it loads faster. TNG has many complicated combinations depending on user selections, settings and mods so I did not attempt to cache additional pages.

This mod has two modes of operation. The default mode (0) reads the time the cache was created and then compares to a time limit that is set in the options menu in seconds. The default is set at 86400 seconds or twenty-four hours. This is intended for sites with many contributors so the page can be updated on a regular schedule. The second mode (1) is for sites that prefer updating the cache files manually. You can delete the cache files using a button in the options menu. Although cache files can be deleted at any time in either mode. You can change the mode and default time using the mod's Edit Options menu.

The mod creates three cache files, one for desktops and two for mobile devices in the HTML format. Cache files are not created until someone selects statistics from the TNG menu. So the first time the page is cached, it loads at the normal speed and caches the page according to the user agent that is currently active, desktop, mobile or mobile in the standard mode. The cache files use the default template css styling so if you decide to change templates the cached pages are not affected.

On smaller websites this mod may not be worth installing but on my family website, the page load time dropped from 7.1 seconds to 625ms on TNG v12. Note that TNG v13 is faster but I did not check the load time.

The MOD was rewritten to correct the following:
  • Fixed the paths so cache works with TNG in the root or in a sub-folder.
  • Added detecting the active useragent so the correct cache file is loaded. (Desktop, mobile or mobile in desktop mode)
  • Cache files were renamed so they appear next to the php file page that was cached.
  • You must be logged in as administrator to delete cache files.
  • Updated mod to eliminate the cache folder.
The mod was tested with TNG v13.0.1 through v13.0.4 both in the root and inside WordPress.
TNG WIKI download link

statistics_cache_v13.0.1.1.zip
(2.09 KiB) Downloaded 1026 times


The mod was tested with TNG v11.0.1 through v12.3 both in the root and inside WordPress.
statistics_cache_v11.0.1.6.zip
(1.97 KiB) Downloaded 1398 times



To install, unzip all content to the TNG mods folder. Launch mod manager and select install.

If you decide to delete the mod, first delete the cache files using edit options then uninstall and delete the mod.
 
Post Reply