PlaidWeb / Publ

Flexible publishing system for the web
http://publ.beesbuzz.biz/
MIT License
40 stars 4 forks source link

Defer the rendering of images to the first actual request #493

Closed fluffy-critter closed 2 years ago

fluffy-critter commented 2 years ago

Summary

Only render an image when it's first requested by a browser. Fixes #455

Detailed description

Instead of immediately scheduling images for rendering at page-render time, this shoves the render request into an unwieldy, grotesquely-long URL that encodes the render request state, and then the _async image handler is responsible for generating the render request from that.

This uses signed URLs to avoid situations where someone may construct a malicious render request externally. The downside is that in a load-balanced scenario, this requires that all backing instances use the same app.secret_key or that the load balancer provides strong connection affinity, but that's currently the case for all user authentication as well.

Developer/user impact

There should be no impact on users, aside from some edge cases where images will fail to load if a page is requested immediately before a Publ deployment occurs but before the images get rendered.

Test plan

Unit tests continue to pass, and manually removed the tests/static/_img directory to smoke-test various scenarios.

Got a site to show off?