[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[snapshot/master] Set expires headers for /



---
 web/app/snapshot/config/deployment.ini_tmpl |    4 +++-
 web/app/snapshot/controllers/root.py        |    1 +
 web/app/snapshot/lib/app_globals.py         |   10 ++++++++--
 3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/web/app/snapshot/config/deployment.ini_tmpl b/web/app/snapshot/config/deployment.ini_tmpl
index 01ac778..e41684d 100644
--- a/web/app/snapshot/config/deployment.ini_tmpl
+++ b/web/app/snapshot/config/deployment.ini_tmpl
@@ -32,7 +32,9 @@ snapshot.db.user = guest
 snapshot.farmpath = /srv/snapshot.debian.org/farm
 
 expires.static = 900
-expires.archive.index = 600
+
+expires.root = 900
+
 expires.archive.dir = 600
 expires.archive.file = 864000
 
diff --git a/web/app/snapshot/controllers/root.py b/web/app/snapshot/controllers/root.py
index c6c35cc..80a0908 100644
--- a/web/app/snapshot/controllers/root.py
+++ b/web/app/snapshot/controllers/root.py
@@ -16,6 +16,7 @@ class RootController(BaseController):
             db = DBInstance(g.pool)
             c.names = link_quote_array(g.shm.archives_get_list(db))
             c.srcstarts = link_quote_array(g.shm.packages_get_name_starts(db))
+            set_expires(int(config['app_conf']['expires.root']))
             return render('/root.mako')
         finally:
             db.close()
diff --git a/web/app/snapshot/lib/app_globals.py b/web/app/snapshot/lib/app_globals.py
index a2727b4..7375af2 100644
--- a/web/app/snapshot/lib/app_globals.py
+++ b/web/app/snapshot/lib/app_globals.py
@@ -28,8 +28,14 @@ class Globals(object):
         self.pool = PooledDB(psycopg2, 5, **db_config)
         self.shm = SnapshotModel(app_conf['snapshot.farmpath'], self.pool)
 
-        for key in ('expires.package.mr.list', 'expires.package.mr.source', 'expires.package.mr.source_version'):
-            if not key in config['app_conf']: config['app_conf'][key] = 5
+        default_expires = {}
+        default_expires['expires.package.mr.list'] = 300
+        default_expires['expires.package.mr.source'] = 300
+        default_expires['expires.package.mr.source_version'] = 300
+        default_expires['expires.root'] = 1800
+
+        for key in default_expires:
+            if not key in config['app_conf']: config['app_conf'][key] = default_expires[key]
 
         try:
             self.thishost = open('/etc/hostname').read()
-- 
1.5.6.5


Reply to: