About the Project
Pixie is a simple, effective and smart image proxy for Steem blockchain applications.
Pull Request for the Contribution
This contribution introduces IPFS integration, PHP-PM server for easy server-load and Smart browser caching hints.
Every image parsed by Pixie now is also stored on IPFS, meaning IPFS servers both as a caching layer and redundant URLs for the parsed images.
Nginx was replaced with PHP-PM, a pure PHP process manager and web server.
PHP-PM enables lowering the resources consumed by PHP, meaning a huge amount of images can be proxied in parallel with modest server hardware.
Smart Browser Caching Hints
Since IPFS is now integated, when a given URL is proxied and added to IPFS, the response contains the following headers:
Content location provides the alternative direct IPFS URL for loading the same image, on applications that use a fetch API this header can be used as fallback.
The eTag header contains the IPFS hash for the proxied image, effectively working as caching helper for the server.
When a request hits the server, if previously proxied, that header will be sent back to the server by the browser, and the server can just return a 304 (not-modified) response.
Notice this rule is evaluated on the server by the expiration also, meaning the server will return fresh content after a sensitive caching period.
Also notice, that 304 responses do not include a content body, they just confirm the content on the browser cache is still valid.
This header contains the same URL on the
content-location header, but for pre-fetching purposes.
Take a look on the example:
<https://ipfs.blocker.press/ipfs/QmRyo61SD3Zk2rxsPhTtrX1cjfBZmCUAnFN6PSsoLQAbeR>; rel=preload; as=image; crossorigin
This header actually tells the browser to preload the IPFS URL after receiving the content, this creates a cache on the browser on both Pixie URL and IPFS URL, meaning any of those that later be hit, will already be present on browser.
Also, this would allow caching 302 redirects to IFPS links.