<commit_before>/*
Written by <NAME>
Copyright (c) 2010
http://github.com/greim
*/

/**
Plugin to return an expires header.
usage: @expires(days, hours, minutes, seconds)
example: @expires(4,3,2,1) will send an expires header causing the response to
expire 4 days, 3 hours, two minutes, and one second from now.
*/

exports.run = function(api) {

	var days = parseInt(api.arg(0)) || 0;
	var hours = parseInt(api.arg(1)) || 0;
	var minutes = parseInt(api.arg(2)) || 0;
	var seconds = parseInt(api.arg(3)) || 0;

	var ms = 0;

	ms += days    * 1000 * 60 * 60 * 24;
	ms += hours   * 1000 * 60 * 60;
	ms += minutes * 1000 * 60;
	ms += seconds * 1000;

	var expires = new Date();
	expires.setTime(expires.getTime() + ms);

	var ri = api.getResponseInfo();

	if (ms > 0) {
		ri.headers.expires = expires.toUTCString();
	} else {
		delete ri.headers.expires;
	}

	api.notify();
};
<commit_msg>added logic for cache-control header<commit_after>/*
Written by <NAME>
Copyright (c) 2010
http://github.com/greim
*/

/**
Plugin to return expiry/cache-control headers.
usage: @expires(days, hours, minutes, seconds)
example: @expires(4,3,2,1) will send expiry headers causing the response to
expire 4 days, 3 hours, two minutes, and one second from the time of the
request.
*/

exports.run = function(api) {

	var days = parseInt(api.arg(0)) || 0;
	var hours = parseInt(api.arg(1)) || 0;
	var minutes = parseInt(api.arg(2)) || 0;
	var seconds = parseInt(api.arg(3)) || 0;

	var secs = 0;

	secs += days    * 60 * 60 * 24;
	secs += hours   * 60 * 60;
	secs += minutes * 60;
	secs += seconds;

	var expires = new Date();
	expires.setTime(expires.getTime() + secs * 1000);

	var ri = api.getResponseInfo();

	if (secs > 0) {
		ri.headers.expires = expires.toUTCString();
		ri.headers['cache-control'] = 'max-age='+secs;
	} else {
		delete ri.headers.expires;
		delete ri.headers['cache-control'];
	}

	api.notify();
};

{'fraction_non_alphanumeric': 0.16307206733298263, 'fraction_numerical': 0.04418726985796949, 'mean_word_length': 3.661764705882353, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2179772', 'n_tokens_mistral': 780, 'n_tokens_neox': 689, 'n_words': 205}