From 4bfc14555680e861df8ce09c0d9e309bdc1509fd Mon Sep 17 00:00:00 2001
From: RaNaN <Mast3rRaNaN@hotmail.de>
Date: Mon, 16 Dec 2013 11:49:01 +0100
Subject: improved caching directives, tell browser not to cache the index page

---
 pyload/web/pyload_app.py | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/pyload/web/pyload_app.py b/pyload/web/pyload_app.py
index 1a54c4a93..597f1525b 100644
--- a/pyload/web/pyload_app.py
+++ b/pyload/web/pyload_app.py
@@ -62,6 +62,7 @@ def i18n(lang=None):
 
     return json_dumps({})
 
+
 @route('/')
 def index():
     if UNAVAILALBE:
@@ -84,15 +85,14 @@ def index():
         resp.body = template(content, ws=ws, web=web, setup=setup, external=external, prefix=PREFIX)
         resp.content_length = len(resp.body)
 
+    # tell the browser to don't cache it
+    resp.headers["Cache-Control"] = "no-cache, must-revalidate"
+
     return resp
 
 # Very last route that is registered, could match all uris
 @route('/<path:path>')
 def serve_static(path):
-    response.headers['Expires'] = time.strftime("%a, %d %b %Y %H:%M:%S GMT",
-                                                time.gmtime(time.time() + 60 * 60 * 24 * 7))
-    response.headers['Cache-control'] = "public"
-
     # save if this resource is available as gz
     if path not in GZIPPED:
         GZIPPED[path] = exists(join(APP_ROOT, path + ".gz"))
@@ -107,6 +107,9 @@ def serve_static(path):
     resp = static_file(path, root=APP_ROOT)
     # Also serve from .tmp folder in dev mode
     if resp.status_code == 404 and APP_PATH == "app":
-        return static_file(path, root=join(PROJECT_DIR, '.tmp'))
+        resp = static_file(path, root=join(PROJECT_DIR, '.tmp'))
+
+    if resp.status_code == 200:
+        resp.headers['Cache-control'] = "public"
 
     return resp
\ No newline at end of file
-- 
cgit v1.2.3