From f442c984c17178637fae3cd4acf2ae9447b91127 Mon Sep 17 00:00:00 2001 From: Gregory Short Date: Thu, 9 Sep 2010 02:41:11 -0500 Subject: [PATCH] If -c or --cachelife option is <= 0, the ?c= parameter won't be appended to tile urls so that caching can be controlled server-side (or left to the whim of the browser) --- gmap.py | 2 +- template.html | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/gmap.py b/gmap.py index 7cf832e..5578f30 100755 --- a/gmap.py +++ b/gmap.py @@ -15,7 +15,7 @@ helptext = """ def main(): parser = OptionParser(usage=helptext) parser.add_option("-p", "--processes", dest="procs", help="How many chunks to render in parallel. A good number for this is 1 more than the number of cores in your computer. Default 2", default=2, action="store", type="int") - parser.add_option("-c", "--cachelife", dest="cachelife", help="How many minutes a tile will be considered valid by the web browser before it fetches a new copy. Used if you have a crontab or similar running this every once in a while. Default is 24 hours.", default=1440, action="store", type="int") + parser.add_option("-c", "--cachelife", dest="cachelife", help="How many minutes a tile will be considered valid by the web browser before it fetches a new copy. Used if you have a crontab or similar running this every once in a while. Default is 24 hours.", default=0, action="store", type="int") options, args = parser.parse_args() diff --git a/template.html b/template.html index 4d86b25..e5eee0d 100644 --- a/template.html +++ b/template.html @@ -35,8 +35,10 @@ } } url = url + '.' + config.fileExt; - var d = new Date(); - url += '?c=' + Math.floor(d.getTime() / (1000 * 60 * config.cacheMinutes)); + if(config.cacheMinutes > 0) { + var d = new Date(); + url += '?c=' + Math.floor(d.getTime() / (1000 * 60 * config.cacheMinutes)); + } return(url); }, tileSize: new google.maps.Size(config.tileSize, config.tileSize),