Building Taka Astronomy, a swipeable feed of NASA's picture of the day
I added a small new page to this site: Taka Astronomy. It shows NASA’s Astronomy Picture of the Day (APOD) as a full-screen feed that you can swipe through, one picture at a time.
Why I made it
APOD has published a space picture almost every day since June 16, 1995. That is a big and beautiful archive, but it is not easy to browse on a phone. I wanted something simple: open the page, see today’s picture fill the screen, and swipe back in time.
What it does
- A vertical feed. Each picture fills the screen. Swipe or scroll to move, or use the arrow keys on a computer.
- Endless history. When you reach the last loaded picture, it loads the next ten older days, all the way back to 1995.
- Tap to zoom. Tap a picture to open a zoom viewer with pinch, mouse wheel, and button controls.
- Descriptions and credits. NASA’s explanation and the image credits sit behind an expand button, so they stay out of the way until you want them.
- Shareable links. The address bar updates to
?date=YYYY-MM-DDas you scroll, so the link always points at the picture you are looking at. For example,?date=2025-01-02opens that day. - Videos too. Some APOD days are videos, and they show in the feed as well. YouTube and Vimeo videos show a preview image and load the player only when you tap, so swiping still works. Video files play right in the feed, muted, with controls. Zoom and the picture cache are for images only.
Design choices
The page is built touch-first. A full-screen vertical feed is a pattern most people already know from their phones, so it needs no instructions. On a computer, the same layout works with scrolling and the keyboard.
Loading ten days at a time keeps each request to the NASA API small. The page only fetches what you are likely to see next, instead of trying to load thirty years of data at once. If a request fails, the pictures already loaded stay on screen and a retry button appears at the end of the feed.
Caching
The app uses NASA’s free API, which has rate limits, and the pictures can be large. So most of the work went into not asking for the same thing twice. There are three layers:
- Text cache in IndexedDB. Titles, descriptions, credits, and picture and video URLs are saved in the browser’s IndexedDB storage by date. The cache is capped at 50 MB. When it gets full, it drops the least recently viewed dates first, so the days you looked at recently stay cached. Every published entry, including today’s, is kept for 30 days. A date with no post yet is checked again after 15 minutes. If IndexedDB is not available, the cache lives in memory for that visit.
- Rate-limit cooldown. If NASA says the page is sending too many requests, the app stops calling the API until NASA says it is OK to try again, or for one hour if NASA does not say. Cached pictures still work during the cooldown.
- Image cache in a service worker. A service worker is a small script that sits between the page and the network. It saves downloaded pictures, including video preview images, so going back to one you already saw loads instantly. The picture cache is capped at 200 MB, measured by each picture’s real size. When it gets full, the least recently viewed pictures are removed first. Some image hosts do not let the app read a picture’s size. Those pictures still show, but they are not saved.
flowchart LR
A[Feed needs a day] --> B{In IndexedDB?}
B -- yes --> D[Show title and text]
B -- no --> C{In cooldown?}
C -- yes --> W[Wait and show error]
C -- no --> N[NASA APOD API] --> S[Save, up to 50 MB] --> D
D --> I{Picture in service worker cache?}
I -- yes --> F[Show picture]
I -- no --> G[Download and save, up to 200 MB] --> F
All of these caches live in your own browser. They make repeat visits faster and kinder to NASA’s quota, but a new visitor still starts from scratch.
How it is deployed
Taka Astronomy lives in its own private source repository and deploys separately from this blog, using the same private source and public output pattern I described in an earlier post. It just shares the same domain. I can update the app without touching the blog, and the other way around.
Try it
Open Taka Astronomy, swipe back a few years, and see what the sky looked like on a day you remember.