-
Notifications
You must be signed in to change notification settings - Fork 27.5k
feat(http): allow caching for JSONP requests #8356
Conversation
Thanks for the PR! Please check the items below to help us merge this faster. See the contributing docs for more information.
If you need to make changes to your pull request, you can update the commit with Thanks again for your help! |
This was far more trivial than I initially expected 👀 |
Hi
|
Hi @shahata - did you check that this actually works in practice, since the original issue discusses the fact that the |
Actually looking deeper into the code it seems that the cache check is done in |
Yes, I also noticed that comment, but from what I see it is either wrong or maybe the code has changed since then, because now the url manipulation is decoupled nicely from the cache. |
Here's the plunker I played with to see that it works in practice - http://plnkr.co/edit/XRCFYD7KlgvLTLGPtTcn?p=preview |
Here is another version of the Plunker: http://plnkr.co/edit/bs7joENeXtEW6LzzvVBB?p=preview |
So LGTM - I'll merge |
@@ -886,7 +886,8 @@ function $HttpProvider() { | |||
promise.then(removePendingReq, removePendingReq); | |||
|
|||
|
|||
if ((config.cache || defaults.cache) && config.cache !== false && config.method == 'GET') { | |||
if ((config.cache || defaults.cache) && config.cache !== false && | |||
(config.method === 'GET' || config.method === 'JSONP')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JSONP requests are always essentially GET requests, so it would be cool if we could just rename the method to GET --- but this would take a bit more refactoring, so this is fine for now.
I think this implementation is generally fine, so LGTM
Closes #1947