如何删除Javascript缓存?

时间:2019-06-14 19:09:25

标签: javascript angularjs

我正在使用带有i18n的angularjs进行翻译。问题是我需要一种制作版本的方法,因为每次都会从缓存中加载

i18n/lang-en.json

有什么线索可以做什么,使lang-xx.json具有版本,这样我就不会在此文件中获得缓存了吗? 它们没有从任何地方加载,但我认为可以在我的configLang.js中修复

angular.module('moduleApp.config', ['xxx.ui.commons.defaults.config.lang']);

angular.module('moduleApp.config').config(['$translateProvider', '$languageSupportProvider', function($translateProvider, $languageSupportProvider){

        // add your module specific language file to the loading chain
        // $languageSupportProvider.addLanguageFileLocation('plugins/moduleApp/i18n/moduleApp-lang-:optionsKey.json', {});

    }]
);

1 个答案:

答案 0 :(得分:0)

例如,您可以将哈希作为查询字符串添加到TranslateHttpLoader

export function HttpLoaderFactory(http: HttpClient) {
  return new TranslateHttpLoader(http, '/assets/i18n/', '.json?cb=' + new Date().getTime());
}

github问题中有其他解决方案:Cached JSON file