Skip to content

Instantly share code, notes, and snippets.

@lloyd
Created February 17, 2012 01:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lloyd/1849619 to your computer and use it in GitHub Desktop.
Save lloyd/1849619 to your computer and use it in GitHub Desktop.
The patch you didn't want to see
diff --git a/bin/browserid b/bin/browserid
index 5802ba3..482108e 100755
--- a/bin/browserid
+++ b/bin/browserid
@@ -26,7 +26,8 @@ metrics = require('../lib/metrics.js'),
logger = require('../lib/logging.js').logger,
forward = require('../lib/http_forward'),
shutdown = require('../lib/shutdown'),
-views = require('../lib/browserid/views.js');
+views = require('../lib/browserid/views.js'),
+postprocess = require('postprocess');
var app = undefined;
@@ -180,6 +181,18 @@ app.use(function(req, res, next) {
next();
});
+// replace urls in CSS with perma urls with far future expiration for
+// optimal caching
+app.use(postprocess(function(req, content) {
+ if (req.res.getHeader('content-type').indexOf('text/css') === 0) {
+ content = content.toString().replace(
+ /url(\s*\'([^\']*)\'\s*)/, function(str, url) {
+ return "url('" + cachify.hashify(url) + "')";
+ });
+ }
+ return content;
+}));
+
app.use(express.static(static_root));
// open the databse
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment