New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

cache-control

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cache-control - npm Package Compare versions

Comparing version 0.1.1 to 1.0.0

29

index.js

@@ -7,2 +7,3 @@ var path = require('path');

var regular = require('regular');
var onHeaders = require('on-headers');

@@ -16,17 +17,19 @@ module.exports = function (options) {

var _rel = slash(pathname);
_.each(Object.keys(options), function (globKey) {
var _glob = slash(globKey);
if (minimatch(_rel, _glob) && !matched) {
var val = options[globKey];
matched = true;
onHeaders(res, function () {
res.setHeader('Cache-Control', 'public, max-age=300');
_.each(Object.keys(options), function (globKey) {
var _glob = slash(globKey);
if (val === false) res.setHeader('Cache-Control', 'no-cache');
else if (isNumber(val)) res.setHeader('Cache-Control', 'public, max-age=' + val.toString());
else if (_.isString(val)) res.setHeader('Cache-Control', val);
}
if (minimatch(_rel, _glob) && !matched) {
var val = options[globKey];
matched = true;
if (val === false) res.setHeader('Cache-Control', 'no-cache');
else if (isNumber(val)) res.setHeader('Cache-Control', 'public, max-age=' + val.toString());
else if (_.isString(val)) res.setHeader('Cache-Control', val);
}
});
});
if (!matched) res.setHeader('Cache-Control', 'public, max-age=300');

@@ -33,0 +36,0 @@ next();

{
"name": "cache-control",
"version": "0.1.1",
"version": "1.0.0",
"description": "Express/Connect middleware to set url cache options with globs",

@@ -37,2 +37,3 @@ "main": "index.js",

"minimatch": "^0.4.0",
"on-headers": "^1.0.0",
"regular": "^0.1.6",

@@ -39,0 +40,0 @@ "slasher": "^0.1.5"

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc