SectionKnowledge BaseTopicCachingDepthComplete reference
Quick Answers
  • Why browser-cached graphs show yesterday's data
  • Query-parameter cache busting with template variables
  • HTTP Cache-Control headers for weather images
  • CDN purge strategies for Cloudflare, AWS, and others
  • Balancing freshness against bandwidth for graph images

Few things frustrate station operators more than uploading a fresh graph every five minutes, only to have visitors report they see yesterday’s data. The culprit is almost always caching — browser, proxy, or CDN — serving a stored copy instead of fetching the latest version. This guide walks through the caching layers between your station and the viewer’s screen, and provides field-tested solutions that work across the common hosting environments used by weather-station publishers. For the broader publishing context, see Publishing Fundamentals.

How Browser Caching Works

When a browser downloads an image, it stores a local copy keyed by the full URL including query parameters. On subsequent requests, the browser checks its cache rules:

The problem for weather graphs: the filename typically stays the same (temp_24h.png), so the browser treats every request as the same resource and serves from cache.

Cache-Busting with Query Parameters

The most reliable technique is appending a unique query parameter to the image URL at each publish cycle. Since the browser uses the full URL as the cache key, a different query string forces a fresh fetch:

<!-- In your template -->
<img src="/images/temp_24h.png?v=<%publish_timestamp%>"
     width="800" height="400"
     alt="24-hour temperature graph" />

The publish_timestamp variable changes at each upload cycle, generating URLs like temp_24h.png?v=1709654400. The browser sees a new URL and fetches the latest version.

Alternative: File Hash Naming

A more aggressive approach renames the file itself with a hash or timestamp:

<img src="/images/temp_24h_<%hash%>.png" ... />

This is more work to set up but ensures no caching layer can serve a stale version. The downside is that old files accumulate on the server unless you add a cleanup routine.

HTTP Cache-Control Headers

Server-side headers tell browsers and CDNs how long to cache a resource. For weather graphs that update every few minutes, configure headers that balance freshness against bandwidth:

# For weather graph images
Cache-Control: public, max-age=120, must-revalidate

# For static assets that rarely change (CSS, fonts)
Cache-Control: public, max-age=31536000, immutable

A max-age=120 (2 minutes) for graph images means the browser caches the image for at most 2 minutes before revalidating. Combined with query-parameter cache busting, this provides a solid two-layer defence against stale images.

CDN-Specific Notes

Troubleshooting Matrix

SymptomLikely CauseFix
Graph shows old data even after hard refreshCDN serving cached versionCheck CDN cache rules; purge CDN cache; add query-parameter cache busting
Graph updates on one browser but not anotherDifferent cache states per browserClear cache in the stale browser; implement cache busting so all browsers get fresh copies
Query parameter changes but image still staleCDN stripping query parameters from cache keyConfigure CDN to include query strings; or switch to filename hashing
Mobile shows stale, desktop shows freshMobile browser aggressive caching or mobile CDN proxyAdd Cache-Control: no-cache for graph paths; or use file hashing
All graphs stale, HTML is freshImage upload order issue — HTML uploaded before imagesConfigure upload order: images first, HTML last. See FTP Publishing

FAQ

Does cache busting increase bandwidth usage?
Slightly. Each new query parameter forces a fresh download. For typical weather graphs (50–200 KB), the increase is negligible compared to the frustration of showing stale data. If bandwidth is a concern, set max-age to your publish interval so the browser only re-fetches once per cycle.
Should I use no-cache headers for all images?
Only for frequently-changing images like weather graphs. Static images (logos, icons, photos) should use long cache lifetimes. Be selective — blanket no-cache increases server load and page load times.
My ISP provides a transparent proxy — does that affect caching?
Yes. Some ISPs cache content in their network to reduce bandwidth. HTTPS connections bypass transparent proxies (they cannot inspect encrypted traffic). Ensure your site is served over HTTPS.