Skip to content

Expires value gets sometimes automatically set to null #211

Description

@valnub

Hi there,
I am using angular-cache 4.4.3 like this:

Configuration

  CacheFactory('listCacheOnline', {
    maxAge: 15 * 60 * 1000, // Items added to this cache expire after 15 minutes
    deleteOnExpire: 'aggressive', // Items will be deleted from this cache when they expire
    storagePrefix : 'my.news.',
    capacity : 1,
    storageMode: 'localStorage'
  });

Get data:

  $http.get(url, {cache: CacheFactory.get('listCacheOnline')}).then(function (result) {
    doSomethingWith(result);
  });

As you can see I am using 15 min expire time, so after 15 mins I'd expect that angular-cache invalidates this cache entry and gets fresh data from the server. I noticed though that this sometimes does not work. After running my app for a while (especially after not using it for a day or so) I noticed that it won't get the fresh data from the server any more.

When I looked into the issue I saw that the "data" value in localStorage had an attribute called "expires". This is sometimes set to null. If this happens my app will never get fresh data from the server and is stuck at this point. I have to manually flush localStorage and then it starts working normally again with "expires" actually containing a timestamp value until it stops working again when this null value reappears out of nowhere.

So, my question is: How is it possible that expires is set to null with the configuration set above?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions