diff --git a/lib/adapter/adapter.py b/lib/adapter/adapter.py index f33babb..ffa55ec 100644 --- a/lib/adapter/adapter.py +++ b/lib/adapter/adapter.py @@ -145,6 +145,7 @@ class Adapter(with_metaclass(AdapterMC, object)): 'topic': topic, 'topic_type': self._adapter_name, 'format': self._get_output_format(topic), + 'cache': self._cache_needed, } answer_dict.update(answer) diff --git a/lib/adapter/upstream.py b/lib/adapter/upstream.py index 28fa7ba..786d9b2 100644 --- a/lib/adapter/upstream.py +++ b/lib/adapter/upstream.py @@ -58,7 +58,7 @@ class UpstreamAdapter(Adapter): + "?" + options_string try: response = requests.get(url, timeout=CONFIG["upstream.timeout"]) - answer = response.text + answer = {"cache": False, "answer": response.text} except requests.exceptions.ConnectionError: answer = {"cache": False, "answer":_are_you_offline()} return answer diff --git a/lib/routing.py b/lib/routing.py index b471373..1247c43 100644 --- a/lib/routing.py +++ b/lib/routing.py @@ -182,7 +182,8 @@ class Router(object): } answer = self._get_page_dict(topic, topic_type, request_options=request_options) - cache.put('q:' + topic, answer) + if answer.get("cache", True): + cache.put('q:' + topic, answer) return answer # Try to find cacheable queries in the cache.