drupflare/worker - v1.0.0
    Preparing search index...

    Function orderByViews

    • Orders queued paths by how much traffic mirroring each one actually moves off the Worker.

      THE OPTIMUM IS A SHARE OF VIEWS, NOT A COUNT OF PAGES, and draining in queue order confuses the two. Queue order is roughly fill recency, which is uncorrelated with popularity, so mirroring the first N queued pages moves an unknown share of traffic -- and the whole lever is worthless if it moves the tail instead of the head.

      The hit counts come from an in-memory map on the Durable Object, incremented on the fast serve lane. That costs ZERO rows, which matters because rows written is the meter this lever exists to protect; a hits column would spend the meter to decide how to save it. The counts are lost on eviction, which is fine: the heuristic restarts warm rather than wrong, and a path that is genuinely popular re-earns its place within one alarm cycle.

      A path with no recorded hits sorts last but is NOT dropped -- it was rendered, so something asked for it, and the counter may simply be younger than the page.

      Parameters

      • paths: string[]
      • hits: ReadonlyMap<string, number> | null

      Returns string[]