I using some GeoIP service to place country flag on pages depends on country IP. And I need to cache JSON response for all pages on my site.
This code placed into header.php
:
$.getJSON('http://smart-ip.net/geoip-json?callback=?', function(data) {
$('#flag').html("<a class='fancybox-inline int' href='#international'><img src='/images/flags/"+data.countryCode+".png'></a>");
}
Is it possible to cache it with $.ajaxSetup({ cache: true })
? - seems to not work.
Or probably better to use HTML5 localStorage, but I'm not sure how to do that.
I also tried JSONCache plugin, but it did not work for me.