1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-09-15 15:32:28 +02:00

code reivew: do not cache assets fetched for viewing purpose

This commit is contained in:
gorhill 2017-01-23 10:13:07 -05:00
parent 50800427b3
commit 96df129ddb
2 changed files with 12 additions and 4 deletions

View File

@ -29,7 +29,8 @@
var reIsExternalPath = /^(?:[a-z-]+):\/\//,
reIsUserAsset = /^user-/,
errorCantConnectTo = vAPI.i18n('errorCantConnectTo');
errorCantConnectTo = vAPI.i18n('errorCantConnectTo'),
noopfunc = function(){};
var api = {
};
@ -716,7 +717,14 @@ var saveUserAsset = function(assetKey, content, callback) {
/******************************************************************************/
api.get = function(assetKey, callback) {
api.get = function(assetKey, options, callback) {
if ( typeof options === 'function' ) {
callback = options;
options = {};
} else if ( typeof callback !== 'function' ) {
callback = noopfunc;
}
if ( assetKey === µBlock.userFiltersPath ) {
readUserAsset(assetKey, callback);
return;
@ -755,7 +763,7 @@ api.get = function(assetKey, callback) {
onContentNotLoaded();
return;
}
if ( reIsExternalPath.test(contentURL) ) {
if ( reIsExternalPath.test(contentURL) && options.dontCache !== true ) {
assetCacheWrite(assetKey, {
content: this.responseText,
url: contentURL

View File

@ -57,7 +57,7 @@ var onMessage = function(request, sender, callback) {
switch ( request.what ) {
case 'getAssetContent':
// https://github.com/chrisaljoudi/uBlock/issues/417
µb.assets.get(request.url, callback);
µb.assets.get(request.url, { dontCache: true }, callback);
return;
case 'listsFromNetFilter':