I have a twitter feed on my website which is powerd by the jquery tweet plugin tweet.seaofclouds.com and some other json plugins that take a json feed from a 3rd party website.
The problem is dat the twitter api only allows 150 calls per hour, so with 40 visitors an hour with an average of 5 pageviews per visitor I go way past that max. Especially since twitter disabled caching on the feed.
Also, there is the coockie law problem. Twitter drops cookies when the feed is requested and I don’t want them because they need to have permission to be dropped, so I want to disable them all the way.
Also my website is SSL secure and I want to load as minimal external resources as possible, I want it all localised.
How do I locally cache these json feeds?
For this problem I have written my own database storing mechanism to store the json feeds and fetch them when needed and return them. That way I only need to fetch every 5 minutes and the amount of visitors/pageviews I get is irrelevant.
Here is the database creation code in mysql
Then in PHP I have this code with some security checks since you’ll never know what you’ll get
Then in the twitter.js you only need to replace the getJSON url to point to your local server as follows(somewhere at the bottom of jquery.tweet.js you’ll find this line)
Find:
$.getJSON(build_api_url()).success(function(data){Replace: