Archives Home

Trick: Keeping Browsers from Caching XML | Archives

September 29, 2010

This summer I created a cool implementation of our flash us map.  I created an automatically updating state intensity map for unemployment rates.  It is based on the php code that powers this tool and the FRED API.  Every month, the unemployment rate in each state changes.  When that happens, the web page creates a new XML file with updated data.  This powers the new map.  However, if you’ve visited the page recently your browser will rely on a cache of the old XML file.  And, you won’t see the new data on your map.

What to do?  You could change the name of the XML file.  But, that can be a hassle if your data changes frequently.  I don’t want hundreds of XML files piling up.  The simple solution is simply adding a random parameter to the end of the url pointing to the xml file.  In this case, I specify the location of the XML file using FlashVars.  My code looks like this:

url=map.xml
If I want to keep browsers from caching the file I add a random parameter to the end like so:
url=map.xml?1234567
You want the random character to be something that changes all the time. I just use a time stamp. In php the code looks like this:
url=map.xml<?php $time = time(); echo “?”; echo $time; ?>

How this helps someone!

Home | License | Privacy | Releases | Testimonials | Resources | Documentation | Order Lookup | All Maps | FAQs
Formerly FlashUSAmap.com and FlashWorldMap.com
SimpleMaps.com is a product of Pareto Software, LLC. © 2010-2024.