Pixie: IPFS integration, PHP-PM Server and Smart Browser Caching.

in #utopian-io7 years ago (edited)

About the Project

Pixie is a simple, effective and smart image proxy for Steem blockchain applications.

Repository

https://github.com/blocker-solutions/pixie

Pull Request for the Contribution

PR #2

New Features

This contribution introduces IPFS integration, PHP-PM server for easy server-load and Smart browser caching hints.

IPFS Integration

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.

PHP-PM

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

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.

Example: https://ipfs.blocker.press/ipfs/QmRyo61SD3Zk2rxsPhTtrX1cjfBZmCUAnFN6PSsoLQAbeR

etag

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.

Example: W/"QmRyo61SD3Zk2rxsPhTtrX1cjfBZmCUAnFN6PSsoLQAbeR"

link

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.

GitHub Account

https://github.com/hernandev

Sort:  

Thank you for your contribution. Some nice and useful features added. Though commit messages are ok, if it would be little more descriptive then that would be great.

Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, click here.


Need help? Write a ticket on https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator]

Hey @hernandev
Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!

Contributing on Utopian
Learn how to contribute on our website or by watching this tutorial on Youtube.

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!

Boa Hernandes!

ptgram

Boa, parabéns pela contribuição!


projeto #ptgram power | faça parte | grupo steemit brasil

Parece ser bem útil para quem trabalha na área.

projeto #ptgram power | faça parte | grupo steemit brasil

Não entendo muito sobre esse assunto


projeto #ptgram power | faça parte | grupo steemit brasil

Coin Marketplace

STEEM 0.23
TRX 0.28
JST 0.042
BTC 104956.85
ETH 3880.98
SBD 3.32