kiboit / phast

Automated web page optimization for PHP
https://www.phast.io/
GNU Affero General Public License v3.0
35 stars 1 forks source link

Replace resource URLs by unique IDs #2

Closed apeschar closed 5 years ago

apeschar commented 5 years ago

Currently Phast uses full URLs to request resources from the bundler, along with a signature and a cache salt. This leads to quite long URLs that don't always fit in a single TCP packet, leading GTmetrix to complain, rightly.

Instead, we could generate an ID number for each resource encountered in the document, and use that ID number when retrieving the resource.

  1. During document handling
    1. Look up any existing ID for a resource by URL and cache salt
    2. If no ID is found, generate a new one by encoding a certain amount of random bytes
  2. On the frontend
    1. Attempt to retrieve a resource using its ID
    2. If that doesn't work, fall back using the existing logic