angular.js icon indicating copy to clipboard operation
angular.js copied to clipboard

$http cache doesn't work for JSONP requests

Open tcoopman opened this issue 13 years ago • 7 comments

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

tcoopman avatar Feb 04 '13 08:02 tcoopman

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.

jendib avatar Apr 23 '13 19:04 jendib

I was wondering the same.

iamjohnlong avatar Jun 27 '13 14:06 iamjohnlong

:+1:

Guuz avatar Aug 05 '13 12:08 Guuz

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.

steveruiz avatar Aug 05 '13 14:08 steveruiz

this one is related #3073

cironunes avatar Aug 05 '13 17:08 cironunes

+1

maxbates avatar Apr 15 '14 03:04 maxbates

:+1: great catch

mrpollo avatar Jul 29 '14 19:07 mrpollo