I have mvc / c# / razor app that using the following method / class and I found out our developer put this on Views/Shared/Layoutpage.
It looks like it is called this method everytime when the page is refreshed. As a result, it is super easy to max out the API usage.
My question is: What is the best practice to use cache in c# to reduce this usage? In general, the layoutpage will be loaded as usual.
Please show me how it works in codes/c#. Thanks
public static string GetLatitiudeByIP(string ip)
string returnValue = "34.028623";
XmlDocument foo = new XmlDocument();
" + ip + "?access_key=7efaasdfasdfa
XmlNode latitudeNode = foo.SelectSingleNode("/res
if(latitudeNode != null)
returnValue = latitudeNode.InnerText;