GET request sent to REST API only first time in IE10 - get

I've recently started using Restangular for making cross domain requests to a RESTful service, and so far everything works great.
But with IE10 when a make a GET request only for the first time it gets data from the Server, and for subsequent calls it does not hit the server, and returns probably cached data. I need to get the data refreshed from the Server. I tried setting defaultHttpFields cache to false, but no luck. Please help!
Thanks,
Lakshmi

I'm the creator of Restangular.
Could you please post an example? If you didn't set the cache to true in defaultHttpfields, Restangular shouldn't cache this at all.
Have you chcked if the requests are going out in the Network tab of the developers console? Does it work in other browsers? Check in restangular Library for RestangularResource to see if it's doing $http call.
Hope it helps!

I just hit this one too. Seems that IE10 is particularly keen on caching results from RESTful calls.
One workaround I used was to just provide some unique value as a parameter to each request and then IE10 seems happy not to cache it. I used the current timestamp in ms since I've seen jQuery use similar workarounds in the past.
var postsApi = Restangular.all("posts");
$scope.allPosts = postsApi.getList({ nocache : new Date().getTime() });
Works for now.

Related

ArangoDb: Time from save() to availability through AQL - waitForSync?

In my NodeJS backed REST API, using the ArangoJS library, I'm calling the await save(...) on a document in a collection. Note I'm not using using the waitForSync option.
Right after the await on the save, I'll send a SSE event to the client, which then immediately calls another REST API method, which uses AQL to query the very same collection. Unfortunately I get the previous (old/unchanged) data back. Waiting a sec then AQL-querying gives me the fresh data though.
Is waitForSync the solution? Most documentation states that this option waits for data to sync to the disk, but as I understand ArangoDB keep most data in memory, so it shouldn't affect the following query, which should query against memory?
Anyone care to explain?
Update
see my own answer
Just to mark this as answered:
As expected, there is nothing wrong with ArangoDb. Thanks to the comment/confirmation that await should be enough, I investigated further around my setup. Found that the problem was with caching, and adding a Cache-Control header with 'no-cache' resolved the issue.
Funny thing is that when developer console was open in Chrome, I never had problems. Found that the checkbox 'disable cache' in development mode had hidden the issue during development. Issue being a lot of 304 Not Changed responses.

Best way to request API and store every minute

I have an app that is hitting the rate limit for an API which is hurting the user experience. I have an idea to solve this but have no idea if this is what should be done ideally to solve this issue. Does this idea makes sense and is it a good way to solve this issue? And how should I go about implementing it? I'm using react-native and nodejs.
Here is the idea:
My app will request the data from a "middleman" API that I make. The middle man API will request data once per minute from the main API that I am having the rate limit problem with (this should solve the rate limit issue then) then store it for the one minute until it updates again. I was thinking the best way to do this is spin a server on AWS that requests from the other API every minute (Is this the easiest way to get a request every minute?) then store it on either a blank middleman webpage (or do I need to store it in a database like MongoDB?). Then my app will call from that middleman webpage/API.
Your idea is good.
Your middleman would be a caching proxy. It would act just as you stated. Hava a look at https://github.com/active-video/caching-proxy it does almost what you want. It creates a server that will receive requests of URLs, fetch and cache those, and serve the cached version from now on.
The only downside is that it does not have a lifetime option for the cache. You could either fork to add the option, or run a daemon that would delete the files that are too old to force a re-fetch.
EDIT:
A very interesting addition to the caching-proxy would be to have a head request to know if the result changed. While this is not provided by all API, this could become useful if yours is displaying such info. Only if HEAD requests do not count toward your API limits...

Modifying content delivered by node-http-proxy

Due to some limitations about the web services I am proxying, I have to inject some JS code so that it allows the iframe to access the parent window and perform some actions.
I have built a proxy system with node-http-proxy which works pretty nicely. However I have spent unmeasurable hours trying to modify the content (on my own, using harmon as well, etc) that is being sent to the user without any success. I have found some articles and even some questions here but all of them are outdated and are not useful anymore.
I was wondering if someone can give me an actual example about how to do this, because I am unable to do it and maybe it is just that it is impossible to do at this point?
I haven't tried harmon, but I did try cheerio and it works.
However, I used http-mitm-proxy and not node-http-proxy.
If you are using http-mitm-proxy, you need to return a promise in the response handler. Otherwise, the proxy continues to send the original response without picking up your changes.
I have recently written another proxy at:
https://github.com/noeltimothy/noelsproxy
I'm going to add response handling to this soon. This one uses a callback mechanism, which means it wont return the response until the caller signals it to.
You should be able to use 'cheerio' and alter the content in JQuery style.

Google Places Request Returning "REQUEST_DENIED"

I realise their are numerous questions regarding this issue and I have read them all, but I still cannot get this to work!
I have:
Created my project in the API console
Enabled Places API in services
Created a new IOS API Key (repeated this step twice now)
Tried the request with sensor=true, sensor=false and no sensor param at all
Tried HTTP and HTTPS
Those are all the fixes I found within the existing questions regarding this issue, have I missed anything? Here is a sample URL I am using to test:
https://maps.googleapis.com/maps/api/place/textsearch/json?sensor=true&query=Test%20sd&key=MYKEY
And yes, I am replacing 'MYKEY' with my actual API key :).
I am developing an IOS app using monotouch but I don't really see how that is relevant as I can't get this to work in the browser either.
Any help would be hugely appreciated! Been stuck on this all day now.
I believe you want to be using your "Simple API Access" key (not an Android/iOS key). The documentation mentions this as the last step.
https://developers.google.com/places/documentation/#Authentication
I tried your sample URL with my Simple API Access key and it was successful.

Foursquare Explore API endpoint seems to be broken

I have been using Foursquare Explore API endpoint since I have started developing an application. But recently it seems to be broken. It keeps on giving me following response
warning: {
text: "There aren't a lot of results near you. Try something more general, reset your filters, or expand the search area."
}
I am trying to get the response from the following HTTP URL -
https://api.foursquare.com/v2/venues/explore?ll=40.7,-74&v=20121124
(adding my credentials to the above URL)
the issue has been noticed couple days ago on this page
Foursquare venues/explore returning empty data set
I'd really like foursquare to keep us informed, because we can't rely on their API if no information about what's going on is provided :(
This bug has been fixed, all queries should be working now. Thanks for bringing this issue to our attention.

Resources