Sharing is Caring

I did something interesting to this blog. And by “interesting” I mean it’s interesting to me, but mostly because I’m a developer.

In the sidebar, at the bottom, there is a widget sharing cool blog posts from Phoenix-area bloggers. I use Google Reader and decided to start “sharing” items I liked. Google Reader provides widgets to share public feeds and it’s easy to create a feed and a widget for your “shared items.”

That is cool and I could have used it as-is, but the way it works is you drop some JavaScript code on your site and it will dynamically pull in the recent items when the page loads. To the end-user, this is fine, but what if I want search engines to reward those bloggers when I share their posts? It would also help, SEO-wise, to have pages on the blog updating more actively, however in a very minuscule way.

Time for the nerd talk…
To do this, I took the URL used by the JavaScript widget code, noticed the feed data is formatted in JSON in that file. I wrote a simple PHP script that runs on the server, fetches that file, finds the JSON part of it, decodes the JSON, builds the HTML presentation of the items, and caches that output in a file.

When a user requests a page on this blog, it serves it from the local file and reconnects to Google at most once per hour to update the text. That way, I’m actually decreasing the number of times Google is queried and not hitting it a bunch of times from one location (who knows, maybe they would block my IP).

So when you visit my blog, make sure to glance at that section of the sidebar to see what’s happening elsewhere in the Phoenix blogosphere!

One Reply to “Sharing is Caring”

Leave a Reply

Your email address will not be published. Required fields are marked *