Skip to main content
  1. Blog/

Two Quick Wins for This Blog: Caching and Visitor Analytics

·1 min
Author
Chengyu
I’m Chengyu — a final-year Computer Science student at the University of Sydney. I write about the things I build and break, plus hiking, travel, gaming, and gadgets.
Table of Contents

Two small optimisations to the blog today: adding a caching plugin to speed up page loads, and wiring up visitor analytics.

Enabling the TpCache plugin
#

  1. Go to the TpCache GitHub repo.
  2. Download the plugin: https://github.com/phpgao/TpCache/archive/master.zip
  3. Drop it into the site’s /usr/plugins/ directory.
  4. Unzip it and rename the folder to TpCache.
  5. In the site admin panel, go to Plugins, find TpCache, and enable it.
    • If Memcache/Redis PHP extensions aren’t installed, it’ll fall back to a MySQL-backed driver.
  6. Once it’s configured, force-refresh the homepage to see the effect.
Enabling the TpCache plugin

If you don’t want to bother setting up Redis, that’s as far as you need to go.

Adding Google Analytics
#

  • Open Google Analytics and create a new account in settings.
  • Once created, go into the tracking-code configuration and add it manually.
  • Copy the tracking snippet, then find the header.php file in the current Typecho theme.
  • Paste the snippet in anywhere sensible — you can verify it’s working from the Google Analytics dashboard.
Google Analytics account setup
Adding the tracking snippet
Locating header.php in the theme
Pasting the snippet into place

Related