$http cache doesn't work for JSONP requests
Using the $http with cache doesn't work for JSONP methods. At the moment the cache only works for GET methods, while I think it could be useful to cache JSONP too if the the cache-control headers allow it.
Are there reasons JSONP can't be cached? I think the callback could be a small issue?
- example of the problem: http://plnkr.co/edit/EG7yiZo3poTzxeMOfcUp
- Link to the discussion on G+: https://plus.google.com/u/0/109624499308077610663/posts/H2N7YsRi9CU
After some more research I've found this discussion on the mailinglist and merge request that is looks like it could solve this issue. At the moment the merge request is closed though.
- https://groups.google.com/forum/?fromgroups=#!searchin/angular/$24http$20cache$20jsonp/angular/p9WbhHik31I/aTo9EBYSmbwJ
- https://github.com/angular/angular.js/pull/1548
I have the same question here, why JSONP is not cached? It's not a technical problem, because if we comment out the part checking if it's a GET request, JSONP caching works.
I was wondering the same.
:+1:
It looks like the problem has to do with the way URL's are constructed for JSONP requests. Angular replaces the JSON_CALLBACK parameter value on each request so the URL is unique each time. This URL mismatch causes the cache to miss.
this one is related #3073
+1
:+1: great catch