标签: angular-cache

清除 .angular 文件夹中的角度缓存

从版本开始,13.0.0.angular在根目录中生成一个文件夹,该文件夹会被 git 忽略,其中包含一个cache缓存构建的文件夹。

如何删除(或清除)此缓存?

javascript typescript angular-cache angular-cli angular

44
推荐指数
2
解决办法
7万
查看次数

angular-cache无法按预期工作

我试图将angular-cache模块用于我的项目,但不确定它是否正常工作.以下是代码 -

angular.module('TrackerApp').factory('TrackerFactory', function ($resource, CacheFactory) {
    if (!CacheFactory.get('CenterCache')) {
        console.log('cache does not exists');
        CacheFactory.createCache('CenterCache', {
            maxAge: 5 * 60 * 1000,
            deleteOnExpire: 'aggressive'
        });
    }
    var centerCache = CacheFactory.get('CenterCache');
    var CenterClass = $resource(_ServiceBaseURL + 'api/Center/:id',{},{
        query: {
            method: 'GET',
            cache: centerCache,
            isArray:true
        }
    });
    CenterClass.GetMultipleAsObject = function () { return this.query(); };
    return {
        CenterClass: CenterClass
    };
});
Run Code Online (Sandbox Code Playgroud)

在加载应用程序时,它会在控制台中打印"缓存不存在"的消息,它会在本地存储中创建缓存.它创建了本地存储的关键 -

“angular-cache.caches.CenterCache.keys” = [http://localhost/Services/Tracker/api/Center]
Run Code Online (Sandbox Code Playgroud)

另一个关键是创建

“angular-cache.caches.CenterCache.data.http:// localhost/Services/Tracker/api/Center” = mystoredvalue
Run Code Online (Sandbox Code Playgroud)

问题 -

  1. 在页面刷新(f5),我确实看到再次打印控制台消息,在http调用中,我可以看到"中心"信息正在下载,它不是从缓存中选取的.
  2. 在从一个页面导航到另一个页面时,我看不到控制台消息被打印.但我确实看到"中心"api被调用.数据正在网络选项卡中下载.它应该从缓存中选择.

我觉得它不是从缓存中挑选数据.我错过了什么吗?

caching local-storage angularjs angular-cache angular-local-storage

8
推荐指数
1
解决办法
603
查看次数

使用Restangular取消对服务器的GET请求

我创建了一个UserService,如下所示:

angular.module('nrApp').factory('userService', ['Restangular', 'UserModel', 'DSCacheFactory', function (Restangular, UserModel, DSCacheFactory) {
    // Create a new cache called "profileCache"
    var userCache = DSCacheFactory('userCache', {
        maxAge: 3600000,
        deleteOnExpire: 'aggressive',
        storageMode: 'localStorage', // This cache will sync itself with `localStorage`.
        onExpire: function (key, value) {
            Restangular.oneUrl('users', key).get().then(function(data) {
                userCache.put(key, data);
            });
        }
    });

    Restangular.extendModel('users', function(obj) {
        return UserModel.mixInto(obj);
    });

    Restangular.addRequestInterceptor(function(element, operation, what, url) {
        if(operation === 'get') {
            debugger;
            //Check the cache to see if the resource is already cached
            var data = userCache.get(url); …
Run Code Online (Sandbox Code Playgroud)

caching angularjs restangular angular-cache

6
推荐指数
1
解决办法
2471
查看次数

在 Angular 7 中进行生产构建后,缓存破坏有时不起作用

我们的应用程序使用 node.js Core & Angular 7.2 版

我们经常推出 Angular 应用程序的生产版本,以便在一个月内部署 3-4 次更改。

我收到了一些客户的投诉,他们无法看到更改,除非他们清除缓存或在浏览器中硬重新加载页面。

我认为ng build --prod创建了唯一的哈希值,以便处理缓存破坏,但似乎没有发生。

angular.json我有以下用于生产构建的配置

"production": {
  "optimization": true,
  "outputHashing": "all",
  "sourceMap": false,
  "extractCss": true,
  "namedChunks": false,
  "aot": true,
  "extractLicenses": false,
  "vendorChunk": false,
  "buildOptimizer": true,
  "fileReplacements": [
    {
      "replace": "src/environments/environment.ts",
      "with": "src/environments/environment.prod.ts"
    }
   ]
}
Run Code Online (Sandbox Code Playgroud)

运行后ng build --prod它会生成散列文件,它与基于更改的先前版本不同。此外,我已将服务器配置为不缓存index.html. 那么为什么有时用户需要硬重新加载页面或手动清除缓存以获取最新更改?

除了告诉客户清除他们的缓存之外,我还有什么办法可以解决这个问题?

任何建议将不胜感激。

caching browser-cache angular-cache angular-cli angular

6
推荐指数
1
解决办法
2146
查看次数

$ templateCache的工作原理如何?

我对$ templateCache资源有点困惑;

  • html /模板将存储在服务器端?

  • 或者将存储在浏览器内存中?如果是这样的内存限制是什么?

browser-cache angularjs angular-cache

2
推荐指数
1
解决办法
771
查看次数

AngularJs http 获取缓存不起作用

使用此应用程序:https : //billiving-qa.azurewebsites.net/spa1/#/invoices

一些 http 调用应该被缓存,但由于某种原因这不起作用:

 function getStatuses() {
            return $http.get('/v1/definitions/status', { cache: true })
            .then(function (response) {
                return response.data;
            })
        }
Run Code Online (Sandbox Code Playgroud)

如果您查看网络,您会看到“v1/definitions/status”未缓存,尽管设置了标志。

谢谢

angularjs angular-cache

2
推荐指数
1
解决办法
1164
查看次数