Viqus Logo Viqus Logo
Home
Categories
Language Models Generative Imagery Hardware & Chips Business & Funding Ethics & Society Science & Robotics
Resources
AI Glossary Academy CLI Tool Labs
About Contact

Simon Willison Crafts Persistent Random Tag Navigation in Aggressively Cached Website

dynamic caching JavaScript Django localStorage Cloudflare random navigation web development
January 28, 2026
Source: Simon Willison
Viqus Verdict Logo Viqus Verdict Logo 8
Tactical Innovation
Media Hype 6/10
Real Impact 8/10

Article Summary

Simon Willison’s blog post details a pragmatic approach to enhancing user experience on a heavily cached website. He tackled the challenge of providing a dynamic, persistent ‘random tag’ navigation feature. This involved several layers of complexity, primarily centered around how to interact with Cloudflare’s aggressive caching. Willison leverages Django’s admin interface to manage content types (entries, link posts, quotes, and notes), and then uses JavaScript and localStorage to create a system where users can repeatedly navigate to random posts within a selected tag. The core mechanism uses localStorage to store a 'random_tag' key along with a timestamp. This ensures that the 'Random' button remains active in the header as long as the timestamp is within a 5-second window of the user’s last click. He effectively employed a CTE (Common Table Expression) to efficiently generate a list of tagged content for random selection, addressing the scalability issue of tags with thousands of items. This demonstrates a sophisticated understanding of caching strategies and a desire to optimize the user experience despite the limitations imposed by Cloudflare. The post's detailed explanations, including code snippets and a GIF showcasing the functionality, make it a valuable resource for developers working with performance-sensitive web applications.

Key Points

  • Willison implements persistent random tag navigation to combat the limitations of aggressive caching.
  • The solution utilizes localStorage to store a timestamp, dynamically updating the 'Random' button’s visibility.
  • A CTE (Common Table Expression) is employed for efficient random content selection, scaling to large tag lists.

Why It Matters

This post is significant for several reasons. It highlights a real-world challenge – optimizing user engagement on sites with aggressive caching. It provides a practical, demonstrable solution, demonstrating a deep understanding of caching layers and their impact on user experience. Furthermore, the use of a CTE is a clever optimization, showing an advanced approach to data querying. This case study is particularly relevant for developers building websites and web applications where performance and user interaction are critical. It shows how one can achieve a compelling user experience even with aggressive caching strategies.

You might also be interested in