iftechfoundation / ifdb

The software behind the Interactive Fiction Database (IFDB)
Other
25 stars 18 forks source link

Avoid querying IFWiki whenever a game page is loaded #606

Open salty-horse opened 3 years ago

salty-horse commented 3 years ago

When a browser loads the game page, it makes an AJAX call to IFDB, which makes an HTTP call to IFWiki, looking for a wiki page for the game in question (based on the first IFDB).

This is done every time a page is loaded, which is unnecessary. As discussed in iftechfoundation/ifdb#123, the result should be cached for a reasonable period of time, and the IFWiki link should be returned as part of the page.

alice-blue commented 3 years ago
  • What is a reasonable period of time for which to save positive/negative results?

I can think of only a few reasons why a previously-existing game page on ifwiki might become unavailable:

Since none of these things happens very often, maybe a positive result gets saved for 6 months or so.

Not sure about how long to save a negative result.

dfabulich commented 3 months ago

I pulled some data on this today.

Therefore, I think it makes sense to have a very long cache time, for positive and negative results.

It might even make sense to do a one-time import, adding IF Wiki links as External links to the 1,322 games that have them, and then stop automatically querying IF Wiki at all. Users could manually add/remove links to IF Wiki if/when new game pages were added to the wiki.

Alternately, if IF Wiki could conveniently dump out a list of its IFIDs (?) we could probably query that once a day / once a week, and use that cache instead of directly pinging IF Wiki all the time.

salty-horse commented 3 months ago

Here's an API call to get all IFID prefixes in IFWiki: https://www.ifwiki.org/api.php?action=query&format=json&pslimit=500&list=prefixsearch&pssearch=IFID

It's in pages of 500, so needs extra calls. Mediawiki documentation.

alice-blue commented 3 months ago

IFWiki is in the process of putting together a new games database now. I'm not sure how that might affect how IFIDs are organized/stored/etc. on IFWiki.

salty-horse commented 4 weeks ago

Here's an attempt to query IFWiki directly from the browser instead of going through IFDB, so there's no need for the ifwiki-check API.

It's giving an error about a missing Access-Control-Allow-Origin - Is that missing on IFWiki? Is there away to "allow" it with headers on IFDB?

dfabulich commented 2 weeks ago

1024 moved the request to IFWiki, but I think we should still not bother pinging IFWiki all the time.

My favorite answer is to have a scheduled job that updates an IFDB cache table of IFWiki links.