[#7027] Cache /​nf/​tool_icon_css better

Signed-off-by: Tim Van Steenburgh <tvansteenburgh@gmail.com>
diff --git a/Allura/allura/controllers/static.py b/Allura/allura/controllers/static.py
index 60d77c1..313a877 100644
--- a/Allura/allura/controllers/static.py
+++ b/Allura/allura/controllers/static.py
@@ -43,10 +43,10 @@
         return html
 
     @expose()
-    def tool_icon_css(self):
+    def tool_icon_css(self, *args, **kw):
         """Serve stylesheet containing icon urls for every installed tool.
 
         """
         css, md5 = g.tool_icon_css
-        return utils.serve_file(StringIO(css), 'tool_icon_css', 'text/css',
-                                etag=md5)
+        return utils.serve_file(
+            StringIO(css), 'tool_icon_css', 'text/css', etag=md5)
diff --git a/Allura/allura/lib/app_globals.py b/Allura/allura/lib/app_globals.py
index 9548cac..01713dd 100644
--- a/Allura/allura/lib/app_globals.py
+++ b/Allura/allura/lib/app_globals.py
@@ -601,6 +601,10 @@
     def noreply(self):
         return unicode(config.get('noreply', 'noreply@%s' % config['domain']))
 
+    @property
+    def build_key(self):
+        return config.get('build_key', '')
+
 
 class Icon(object):
 
diff --git a/Allura/allura/lib/utils.py b/Allura/allura/lib/utils.py
index 2096daa..ef6e502 100644
--- a/Allura/allura/lib/utils.py
+++ b/Allura/allura/lib/utils.py
@@ -509,7 +509,8 @@
         x = source()
 
 
-def serve_file(fp, filename, content_type, last_modified=None, cache_expires=None, size=None, embed=True, etag=None):
+def serve_file(fp, filename, content_type, last_modified=None,
+        cache_expires=None, size=None, embed=True, etag=None):
     '''Sets the response headers and serves as a wsgi iter'''
     if not etag and filename and last_modified:
         etag = u'{0}?{1}'.format(filename, last_modified).encode('utf-8')
diff --git a/Allura/allura/templates/jinja_master/master.html b/Allura/allura/templates/jinja_master/master.html
index 0c4d188..dc21fd8 100644
--- a/Allura/allura/templates/jinja_master/master.html
+++ b/Allura/allura/templates/jinja_master/master.html
@@ -29,7 +29,7 @@
 {% do g.register_forge_js('js/pb.transformie.min.js') %}
 {% do g.register_forge_js('js/allura-base.js') %}
 {% do g.register_forge_css('css/forge/hilite.css') %}
-{% do g.register_css('/nf/tool_icon_css', compress=False) %}
+{% do g.register_css('/nf/tool_icon_css?' + g.build_key, compress=False) %}
 {% do g.theme.require() %}
 {% do g.resource_manager.register_widgets(c) %}
 {# paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ #}
diff --git a/Allura/development.ini b/Allura/development.ini
index a410994..3260eb1 100644
--- a/Allura/development.ini
+++ b/Allura/development.ini
@@ -130,6 +130,9 @@
 # static.url_base = ://a.fsdn.com/allura/nf/%(build_key)s/_static_/
 # cdn.url_base = //a.fsdn.com/allura
 
+# default expires header for static resources (1 year in future)
+file_expires_header_secs = 31536000
+
 ew.extra_headers = [ ('Access-Control-Allow-Origin', '*') ]
 
 # SCM settings for local development