curiousdannii/parchment

The Parchment proxy caches in Cloudflare for one week

Closed this issue · 1 comments

When new versions of old files are uploaded, the IF Archive team's policy is to replace the old file in place. https://ifarchive.org/misc/org-procedures.html (See "Replacing old versions")

But iplayif.com sets all of its files to be cached for one week, including all files served up by its proxy.

For example:

$ curl --head "https://iplayif.com/proxy/?url=https://ifarchive.org/if-archive/games/glulx/delphinas-house.gblorb"
HTTP/2 200
date: Mon, 12 Aug 2024 18:26:03 GMT
content-type: text/plain; charset=ISO-8859-1
access-control-allow-origin: *
cache-control: max-age=604800
etag: W/"5f17e45df33d6397c56240425a683a59"
cf-cache-status: HIT

That means that any changes in IF Archive files won't be reflected on iplayif.com for a full week.

I have a few ideas of what to do about this:

  1. IF Archive has CORS headers; there's no need to use the proxy in this case. We could whitelist some domains and list them as not requiring a proxy.
  2. Instead of (or as well as) whitelisting, on the client-side, we could optimistically try to fetch files directly; fall back to the proxy only if the fetch request fails.
  3. Update the Cache-Control header to use stale-while-revalidate https://web.dev/articles/stale-while-revalidate perhaps something like: Cache-Control: max-age=60, stale-while-revalidate=604800.
    Unfortunately, Cloudflare doesn't support stale-while-revalidate yet; they say it's coming later this year.

If the archive is sure it's compressing all storyfiles, then option 1 would be the way to go.