Dynamic Ux On Aggressively Cached Pages Via Client-Side State
Sources: 1 • Confidence: High • Updated: 2026-02-06 16:49
Key takeaways
- Admin-only edit links are conditionally displayed client-side by checking a localStorage key and injecting an edit link from a per-page data-admin-url attribute.
- Clicking the Random button stores the tag name and a timestamp in localStorage before redirecting to a /random/{tag}/ endpoint that selects a random post and redirects to it.
- The content system uses four separate Django models: entries, link posts (blogmarks), quotations, and notes.
- The random tag feature was implemented using Claude Code for web via prompts from an iPhone, including endpoint creation, tests, UI changes, and the localStorage persistence behavior.
- The persistent Random button is only re-injected on page load if the stored timestamp is within the last 5 seconds.
Sections
Dynamic Ux On Aggressively Cached Pages Via Client-Side State
- Admin-only edit links are conditionally displayed client-side by checking a localStorage key and injecting an edit link from a per-page data-admin-url attribute.
- Clicking the Random button stores the tag name and a timestamp in localStorage before redirecting to a /random/{tag}/ endpoint that selects a random post and redirects to it.
- The persistent Random button is only re-injected on page load if the stored timestamp is within the last 5 seconds.
- The website is full-page cached behind Cloudflare with a 15-minute cache header to withstand large traffic spikes.
- Setting localStorage.ADMIN to '1' enables admin edit links in the browser without requiring server-rendered personalization.
- Tag pages include a 'Random' button that redirects users to a random post with that tag and can persist to continue random navigation within the same tag.
Cache Exceptions For Dynamic Redirect Endpoints
- Clicking the Random button stores the tag name and a timestamp in localStorage before redirecting to a /random/{tag}/ endpoint that selects a random post and redirects to it.
- The website is full-page cached behind Cloudflare with a 15-minute cache header to withstand large traffic spikes.
- The /random/{tag}/ endpoint is marked no-cache so Cloudflare will not cache the redirect response.
Data-Model-Driven Query Complexity And Scaling Bottlenecks
- The content system uses four separate Django models: entries, link posts (blogmarks), quotations, and notes.
- Random selection initially used a union across four content tables to assemble candidates for a tag, order them randomly, and redirect based on the selected object.
- The random-selection query was improved using a CTE-based approach to handle large tags more efficiently.
Ai-Assisted Full-Stack Implementation Workflow
- The random tag feature was implemented using Claude Code for web via prompts from an iPhone, including endpoint creation, tests, UI changes, and the localStorage persistence behavior.
Unknowns
- What are the actual performance characteristics of /random/{tag}/ (latency, DB load, error rates) before and after the CTE-based change, especially for tags with thousands of items?
- What specific cache-control directives are used for the no-cache behavior on /random/{tag}/, and is Cloudflare configuration verified to respect them in the deployed environment?
- How is tag membership represented across the four models, and what indexes or database schema choices support efficient random selection across them?
- What are the security and operational implications of using localStorage as the toggle for admin edit links (e.g., whether links expose sensitive admin URLs, and what safeguards exist)?
- What measurable development outcomes resulted from using Claude Code (e.g., lead time, review time, defect rate) compared to non-AI-assisted changes?