0.0.5 • Published 8 years ago

@mrporter/mrp-mod-rewrite v0.0.5

Weekly downloads
1
License
-
Repository
-
Last release
8 years ago

mod_rewrite with remote config middleware

Middleware to configure an instance of connect-modrewrite which, it turn, rewrites URLs based on this configuration.

  • Comes pre-packaged with a rules snapshot, but should be configured to fetch a more up-to-date instance of the rules from a server.
  • Rules are cached to local disk.
  • The cache-control header of the resource at rulesURL is respected; including the ability to serve stale instances of the rule if problems occur downloading a new instance.

Usage

var opts {
    "rulesURL": "http://s3-eu-west-1.amazonaws.com/mod-rewrite-dev/mod-rewrite-test.conf", 
    "preventFallbackToPrepackagedRules": false, // Optional
    "hostnameForRedirects": "www.mrporter.com" // Optional.  Will revert to relative redirects if not specified
    "cacheFileLocation": "./rules-cache", # Not recommended in clustered setup. If specified, reads and writes cachced rules to the supplied file location
    "logger": winston
};
var modRewriteMiddleware = require('mrp-mod-rewrite').createRewriteMiddleware(opts);
app.use(modRewriteMiddleware);

Important

  • The resource at rulesURL must be returned with a MIME type ("content-type" header) of "text/plain"
  • The resource at rulesURL should be returned with a "cache-control" header that includes a "max-age" and a "stale-while-revalidate" directive
    • If a "cache-control" header is not returned, defaults to 10 mins max age and 7-day stale

TODO

  • Timeouts for HTTP connection
  • Consider connection pool, circuit breaker and retry policy for HTTP requests
0.0.5

8 years ago

0.0.4

9 years ago

0.0.3

9 years ago

0.0.2

9 years ago

0.0.1

9 years ago