Skip to content

Caching feed data #22

Description

@olaven

Subtasks

Description

NRSS does not work as well as it should because it gets rate limited by NRK's servers. The current implementation always hits NRK's servers every time a client tries to fetch a feed through the NRSS API (which in turn calls NRK's API). @timharek suggested that Deno KV can be used to store data here, and fetched periodically with Deno Cron. While I believe this is a good idea, I suggest that we fetch the latest episodes on demand, not periodically. Additionally, we can use Deno's queueing system to fetch historical episode data without 1) blocking the user/podcatcher and 2) hitting NRK too hard.

Data requirements

This is the data we use to generate an entry in a podcast feed, which we'd need to store.

type Serie = {
  title: string,
  link: string,
  description: string,
  imageUrl: string,
}

type Episode = {
  title: string, 
  link: string, 
  description: string, 
  id: string, 
  date: Date, 
  durationInSeconds: number, 
}

Getting feed / on demand storing

This is the storage flow I imagine.

sequenceDiagram
    podcatcher ->> nrss: GET /feed
    alt feed in db AND last fetched <= 1h?
        nrss --> podcatcher: return the feed 
    else 
        nrss ->> nrk: GET _latest_ episodes
        nrk --> nrss: episode data
        nrss ->> nrss: store unseen episodes
        note right of nrss: do in the background
        nrss ->> nrss: Deno Queue job to download historic episodes
        nrss --> podcatcher: return the feed 
    end
Loading

Getting historic data

sequenceDiagram
    note right of nrss: might have to spend time here, to avoid rate limits etc.
    nrss ->> nrk: GET _all_ episodes
    nrss --> nrss: store old episodes in the feed 

Loading

EDIT: added subtasks.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions