I get a little grumpy when I open a new browser tab and am not greeted by a random public domain image from the Library of Congress. It’s like someone taking a knife to my IV drip of small joys.

This is enabled by a little gizmo I have taken under my tech wing, the Free to Use Browser Extension created in 2018 by a student intern at the Library of Congress. It has not been updated, but I have kept it alive where I can with my duct tape coding skills.

That was the sadness last night when I kept getting the error message “Searching for Connection” which I usually saw when my internet was out, but that was not the case. I dug out the browser inspector, spotted some 503 errors, poked around the code. In guess mode.

What I had not really sussed before was the data it use was read remotely in Javascript from a JSON file sitting on an Amazon cloud at https://s3.us-east-2.amazonaws.com/lclabspublicdata/loc-img-browser-extension.json. I had never looked at it, but decided to download the file. Now I see, it is all the data from images the extension can possibly display, a 3.1 Mb JSON file with as I determined, 16525 entries, each a data set for image like:

{"url": "https://www.loc.gov/resource/mrg.00193", "imageURL": "https://cdn.loc.gov/service/pnp/mrg/00100/00193v.jpg", "title": "Dog Bark Park, rear view, Route 95, Cottonwood, Idaho", "year": "2004"}

with pretty much clear info for the url for the images page at the Library of Congress, a URL for the image, the image title, and the year it was photographed. I deliberately chose this data example, as I have seen the image before and I know it because I have myself visited Dog Bark Park in Idaho (see how I am diverging from the topic?) -compare mine to the LoC photo in this data element, the one by John Margolies.

2011/365/196 Big Dog / Little Dog / Big Dog
2011/365/196 Big Dog / Little Dog / Big Dog flickr photo by cogdogblog shared under a Creative Commons (BY) license

Anyhow I started wondering if there was a problem accessing the Library of Congress, especially when the error message I saw in the browser yielded a link that gave me an error, over quite a bit of time. I started thinking about the madness of America and its Cheetoh in Chiefs hatred of libraries. I ended up recasting the error page, and well remixing the image as my “statement”

My remixed image with a bit of imaginary editing as to why the LoC server might have been down.

I got an idea though that maybe it was not very efficient for this extension to request a 3Mb data file each time it ran, even if it was cached. I wondered if there was a way to know if this file was continually updated. A call for help in Mastodon:

Hello tech help request line? Let’s say I have a URL for a json file hosted on an amazon cloud thingy, so all i have is that URL – is there any way to find out when it was last updated? HTTP headers??

https://cosocial.ca/@cogdog/114337917798801434

got me the magic trick from D’Arcy Norman (thanks D!)

Well that was easy! Check out what the command line magic revealed:

curl -I https://s3.us-east-2.amazonaws.com/lclabspublicdata/loc-img-browser-extension.json
HTTP/1.1 200 OK
x-amz-id-2: 39RN3hm0GcEe2sLk7+Q0j0mCjFXfpbPg0ghwUXRC55VKBE5hmYj1x8lGE+KTZqsb/Phl1mi/A98=
x-amz-request-id: ARWHGKBZKSSA89BT
Date: Mon, 14 Apr 2025 21:03:18 GMT
Last-Modified: Mon, 10 Dec 2018 19:15:31 GMT
ETag: "ed60baa564f0bfe0ece7c717ed3f39e3"
Accept-Ranges: bytes
Content-Type: application/json
Content-Length: 3091482
Server: AmazonS3

Bingo! This data file has not been updated since December 10, 2018! No need to grab it from the cloud. So I made some mods to the javascript to use Ajax to read the data from a local file now stored in the extension.

It’s all working now, and should be more efficient not relying on the data download. It’s more self contained.

If anyone really is interested, I have created a repo that has this latest fix at https://github.com/cogdog/free-to-use-browser-extension and heck enjoy the prettier version rendered with my own copy of Docsify-This.

I love seeing my random PD images and also smile contently at my own bit of monkeying around with the code by hand, to understand it. No Co-Pilots are needed.


Image Credit: Balchen Repairs Aircraft flickr photo by San Diego Air & Space Museum Archives shared with no copyright restriction (Flickr Commons) Like Balchen, I fix things with a hammer 😉

If this kind of stuff has value, please support me by tossing a one time PayPal kibble or monthly on Patreon
Become a patron at Patreon!
Profile Picture for CogDog The Blog
An early 90s builder of web stuff and blogging Alan Levine barks at CogDogBlog.com on web storytelling (#ds106 #4life), photography, bending WordPress, and serendipity in the infinite internet river. He thinks it's weird to write about himself in the third person. And he is 100% into the Fediverse (or tells himself so) Tooting as @cogdog@cosocial.ca

Leave a Reply

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