Skip to content
Myr

Added res.cache() method

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Tj Holowaychuk · committed by Tj Holowaychuk · parent caec590 · Browse files · 2 files+64 added−7 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+64 added−7 removed

  • tests:+54 added−3 removed
  • other:+10 added−4 removed

2 files+64 added−7 removed

modified:lib/response.js+10 added-4 removed
40 unmodified lines
41 return this;42};4344/**45 * Set Cache-Control to the given `str`.45 * Set Cache-Control to the given `type` and `options`.46 *47 * @param {String} str47 * @param {String} type48 * @param {Object} options49 * @return {ServerResponse}50 * @api public51 */5252res.cache = function(str){53 return this.set('Cache-Control', str);53res.cache = function(type, options){54 var val = type;55 options = options || {};56 if (options.maxAge) val += ', max-age=' + (options.maxAge / 1000); 57 if (options.maxStale) val += ', max-stale=' + (options.maxStale / 1000); 58 if (options.minFresh) val += ', min-fresh=' + (options.minFresh / 1000); 59 return this.set('Cache-Control', val);60};6162/**63 * Send a response.
531 unmodified lines
modified:test/res.cache.js+54 added-3 removed