-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
27 lines (24 loc) · 900 Bytes
/
index.js
File metadata and controls
27 lines (24 loc) · 900 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Batch curl for Prerender caching service
var config = require('./config.js');
var recacheUrls = require('./recache_urls.js');
var curl = require('curlrequest');
var options = {};
if (recacheUrls && recacheUrls.length > 0) {
console.log('Recache ' + recacheUrls.length + ' URLs');
options.url = 'http://api.prerender.io/recache';
options.headers = config.headers;
options.data = config.data;
recacheUrls.forEach(function(url){
var cloneOptions = JSON.parse(JSON.stringify(options));
cloneOptions.data.url = url;
curl.request(cloneOptions, function (err, data) {
if (err) {
console.error('Error: ', cloneOptions.data.url, err);
} else if (data){
console.log(data, cloneOptions.data.url);
}
});
});
} else {
console.log('No URLs to recache. Check recache_urls.js');
}