[英]What is cacheTime in the sitemap node.js module?
cacheTime
是sitemap.js模块在从给定的URL列表重新生成sitemap.xml
文件之前等待的时间。
即。 在第一个请求中,生成sitemap.xml
文件并将其放在缓存中。 后续请求从缓存中读取站点地图,直到它过期并重新生成。
我同意它可以更清楚,但源代码非常清楚。
根据sitemap.js的源代码,第136行:
// sitemap cache
this.cacheEnable = false;
this.cache = '';
if (cacheTime > 0) {
this.cacheEnable = true;
this.cacheCleanerId = setInterval(function (self) {
self.clearCache();
}, cacheTime, this);
}
和第187行:
Sitemap.prototype.toString = function () {
var self = this
, xml = [ '<?xml version="1.0" encoding="UTF-8"?>',
'<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">'];
if (this.cacheEnable && this.cache) {
return this.cache;
}
// TODO: if size > limit: create sitemapindex
this.urls.forEach( function (elem, index) {
// SitemapItem
var smi = elem;
特别:
if (this.cacheEnable && this.cache) {
return this.cache;
}
清除缓存操作上的setInterval
等于给定的cacheTime
参数。
请注意,如果您的网址更改并且您的cacheTime
未触发清除站点地图缓存,则您的站点地图可能会过期。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.