Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Unable to use cache in resource #1475

Closed
@mauvew

Description

@mauvew

First, thanks you very much for creating this amazing generator, it helps a lot and also makes me learning angular much quicker while I am still a beginner.

I found that when I was trying to cache some data I get from the server using cache parameter set as true in $resouce, it still sends the request every time. I have also googled a lot and found that I did it correctly. Is there any other settings I need to do to make this work?

\\\   client\app\components\data\data.service.js

angular.module('nodeApp')
  .factory('DataService', function ($resource) {

    return $resource('/api/data/:controller', {
        id: '@_id'
      },
      {
        market: {
          method: 'GET',
          isArray: true,
          cache: true,
          params: {
            controller:'market'
          }
        },
        marketValue: {
          method: 'GET',
          isArray: true,
          cache: true,
          params: {
            controller:'market-value'
          }
        }
      });
  });

As you see in the code, cache is set as true, but every time I refresh the controller that uses this dataService, it will send the request to ask for the data again. Could you please give some advice?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions