diff --git a/prismic/connection.py b/prismic/connection.py index ae4c21e..0cc9c6d 100644 --- a/prismic/connection.py +++ b/prismic/connection.py @@ -42,7 +42,8 @@ def get_json(url, params=None, access_token=None, cache=None, ttl=None, request_ request_handler = get_using_requests if access_token is not None: full_params["access_token"] = access_token - full_url = url if len(full_params) == 0 else (url + "?" + urlparse.urlencode(full_params, doseq=1)) + sorted_params = OrderedDict(sorted(full_params.items(), key=lambda t: t[0])) + full_url = url if len(full_params) == 0 else (url + "?" + urlparse.urlencode(sorted_params, doseq=1)) cached = cache.get(full_url) if cached is not None: return cached @@ -70,5 +71,9 @@ def get_max_age(headers): if expire_header is not None: m = re.match("max-age=(\d+)", expire_header) if m: - return int(m.group(1)) + # The Prismic API is sending very high expeiery times (10 years) for articles, which + # makes it seem like it's using milliseconds rather than seconds. Some caching libraries + # (including AppEngine Memcache) sees this 10 year value as an error and refuses to + # store or retreive the cached value + return int(m.group(1)) / 1000 return None