Skip to content

Commit

Permalink
unify cache refresh: rename option disableCache to refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
nleush committed Sep 9, 2019
1 parent 29c0b53 commit 657b185
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/cache.js
Expand Up @@ -103,7 +103,7 @@
});
};

if (options && options.disableCache) {
if (options && options.refresh) {

cache_skip_get && cache_skip_get(key);

Expand Down
5 changes: 5 additions & 0 deletions lib/core.js
Expand Up @@ -1367,6 +1367,11 @@
options.jar = request.jar();
}

if ('disableCache' in options) {
console.warn('Using options.disableCache in iframely.run() is deprecated. Use options.refresh instead.')
options.refresh = options.disableCache;
}

generateProviderOptionsFunc(options);

if (options.redirectsCount && options.redirectsCount > (CONFIG.MAX_REDIRECTS || 4)) {
Expand Down
6 changes: 3 additions & 3 deletions lib/utils.js
Expand Up @@ -473,7 +473,7 @@ exports.getImageMetadata = function(uri, options, callback){
], finish);

}, {
disableCache: options.disableCache,
refresh: options.refresh,
doNotWaitFunctionIfNoCache: options.doNotWaitFunctionIfNoCache,
ttl: CONFIG.IMAGE_META_CACHE_TTL || CONFIG.CACHE_TTL,
multiCache: options.multiCache
Expand Down Expand Up @@ -526,7 +526,7 @@ exports.getUriStatus = function(uri, options, callback) {
getUriStatus(uri, options, finish);

}, {
disableCache: options.disableCache,
refresh: options.refresh,
doNotWaitFunctionIfNoCache: options.doNotWaitFunctionIfNoCache,
ttl: CONFIG.IMAGE_META_CACHE_TTL || CONFIG.CACHE_TTL,
multiCache: options.multiCache
Expand Down Expand Up @@ -633,7 +633,7 @@ exports.getContentType = function(uriForCache, uriOriginal, options, cb) {
// Call HEAD.
makeCall();

}, {disableCache: options.disableCache}, cb);
}, {refresh: options.refresh}, cb);
};

exports.unifyDuration = function(duration) {
Expand Down
2 changes: 0 additions & 2 deletions modules/api/views.js
Expand Up @@ -133,7 +133,6 @@ module.exports = function(app) {
maxWidth: getIntParam(req, 'maxwidth') || getIntParam(req, 'max-width'),
promoUri: req.query.promoUri,
refresh: getBooleanParam(req, 'refresh'),
disableCache: getBooleanParam(req, 'refresh'),
providerOptions: getProviderOptionsFromQuery(req.query)
}, cb);
}
Expand Down Expand Up @@ -428,7 +427,6 @@ module.exports = function(app) {
filterNonHTML5: getBooleanParam(req, 'html5'),
maxWidth: getIntParam(req, 'maxwidth') || getIntParam(req, 'max-width'),
refresh: getBooleanParam(req, 'refresh'),
disableCache: getBooleanParam(req, 'refresh'),
providerOptions: getProviderOptionsFromQuery(req.query)
}, cb);
}
Expand Down
2 changes: 1 addition & 1 deletion modules/debug/views.js
Expand Up @@ -13,7 +13,7 @@ module.exports = function(app) {
res.render('debug',{
uri: req.query.uri,
mixAllWithDomainPlugin: !!{"on":1, "true":1}[req.query.mixAllWithDomainPlugin],
disableCache: !!{"on":1, "true":1}[req.query.refresh],
refresh: !!{"on":1, "true":1}[req.query.refresh],
DEBUG: DEBUG,
QUERY: getProviderOptionsQuery(req.query)
});
Expand Down
2 changes: 1 addition & 1 deletion views/debug.ejs
Expand Up @@ -54,7 +54,7 @@
<input type="checkbox" name="mixAllWithDomainPlugin" <% if (mixAllWithDomainPlugin) { %>checked="checked"<% } %>> Debug with all plugins (disable specific mixins and mixin all available plugins) <a href="/debug?uri=<%= encodeURIComponent(uri) || '' %>&mixAllWithDomainPlugin=<%= !!!mixAllWithDomainPlugin %>" target="_blank">or open in new window with opposite value</a>
</label>
<label class="checkbox">
<input type="checkbox" name="refresh" <% if (disableCache) { %>checked="checked"<% } %>> Refresh</a>
<input type="checkbox" name="refresh" <% if (refresh) { %>checked="checked"<% } %>> Refresh</a>
</label>
</div>
</div>
Expand Down

0 comments on commit 657b185

Please sign in to comment.