def get(self): uastring = self.request.headers.get("user_agent") if is_mobile(uastring): self.redirect("/mobile") template = template_env.get_template("index.html") # check if we have a cached result cache_key = 'ventures_all' template_vars = memcache.get(cache_key) # return result from cache if found if template_vars is not None: self.response.out.write(template.render(template_vars)) return logging.info('CACHE MISS: %s' % cache_key) # cache miss so get from datastore ventures = Venture.all() coords = get_coords(ventures) template_vars = {"coords": coords} # add template_vars to cache so subsequent checks are quicker memcache.set(cache_key, template_vars) self.response.out.write(template.render(template_vars))