I am having trouble caching a JSONP request.
I have tried $http.jsonp(url, { cache: true })
and it doesn't appear to be working.
I also tried $http({ method: 'JSONP', url: url, cache: true })
to no avail.
Instead, I've resorted to manually caching the results (very very rough working example below).
Is it possible for AngularJS to do this caching for me?
countries.factory 'Wikipedia',
['$http', '$q', ($http, $q) ->
cache = {}
getSummary: (country) ->
if cache.hasOwnProperty(country)
cache[country]
else
summary = $q.defer()
url = "http://en.wikipedia.org/w/api.php?action=query&prop=revisions&rvprop=content&rvsection=0&rvparse=1&titles=#{country}&format=json&redirects=1&callback=JSON_CALLBACK"
$http.jsonp(url).success (data) ->
# process data ....
paragraphs = ['p1', 'p2']
# return summary content paragraphs
cache[country] = paragraphs
summary.resolve paragraphs
summary.promise
]