Overview

Simon Willison explains how he added dynamic features to his blog that work despite aggressive 15-minute Cloudflare caching. The key insight is using client-side JavaScript with localStorage to add personalized functionality without breaking the cache.

The Breakdown

  • localStorage-based edit links - JavaScript checks for an ‘ADMIN’ key in localStorage and dynamically shows edit buttons only to the site owner, bypassing the need for server-side authentication
  • Client-side like counting - Uses localStorage to track which posts a user has liked, displaying visual feedback without requiring server requests or cache invalidation
  • Progressive enhancement approach - Core content loads from cache instantly, then JavaScript adds personalized features on top, maintaining both performance and functionality
  • Cache-friendly dynamic features - Shows how to add user-specific functionality (admin controls, like buttons) without compromising aggressive caching strategies that protect against traffic spikes