Page MenuHomeMusing Studio

Add cache headers on ActivityPub endpoints
Closed, ResolvedPublic

Description

Overview

We should add caching headers on ActivityPub endpoints so we can use something like Varnish in front of WriteFreely.

Background

Sending out posts on the fediverse cause the heaviest load on a WriteFreely server, as multiple servers all request the same resources within the same small period of time. Combining WF with caching software like Varnish could significantly reduce load on the application (and specifically the database), and this is the first step to enabling that.

Implementation

At the very least, Varnish needs the Cache-Control header. To start, we should set this to a relatively small amount of time only on ActivityPub endpoints like:

  • Collections fetched via canonical URL with activity+json header (e.g. /matt/)
  • Collections fetched via API (e.g. /api/collections/matt)
  • Post fetched via canonical URL with activity+json header (e.g. /matt/my-post)
  • Post fetched via API (e.g. /api/collections/matt/posts/123someid456)

Revisions and Commits