Re: [AngularJS] disable $resource caching?

2,477 views
Skip to first unread message

Tony Polinelli

unread,
Jan 2, 2013, 12:26:23 AM1/2/13
to ang...@googlegroups.com
Probably not the BEST way - but i just added a cache killer:

<div ng-include src=" 'partials/myTemplate.html?rand=' + rand " ></div>

and in a controller on the <body>   -  $scope.rand = Math.random();

Since its on the body - it doesnt change unless the whole page is refreshed. Meaning that it will cache until the app is refreshed, but then get a fresh copy. You could make it refresh EVERYTIME, by setting rand on the views controller (overriding the inherited value)

I wonder if there is a more standard way too?

tony


On Wed, Jan 2, 2013 at 3:41 PM, Lee Owen <itsle...@gmail.com> wrote:
Is anyone familiar with the easiest way to disable cache for all $resource requests?

--
You received this message because you are subscribed to the Google Groups "AngularJS" group.
To post to this group, send email to ang...@googlegroups.com.
To unsubscribe from this group, send email to angular+u...@googlegroups.com.
Visit this group at http://groups.google.com/group/angular?hl=en-US.
 
 



--
Tony Polinelli
http://touchmypixel.com

Tony Polinelli

unread,
Jan 2, 2013, 12:27:01 AM1/2/13
to ang...@googlegroups.com
oh that was for templates... oops. cachekiller on the url set to the request?

Sylvester Keil

unread,
Jan 2, 2013, 6:31:48 AM1/2/13
to ang...@googlegroups.com
You can probably accomplish this by using a request interceptor. See here:

https://github.com/angular/angular.js/pull/1701

And an example here:

https://github.com/angular/angular.js/issues/1418

Best,
Sylvester
Reply all
Reply to author
Forward
0 new messages