The IPFS node out of the box doesn’t cache items in the browser for any length of time, getting the item from a local cache has to be faster than making a full http request.
That’s not exactly accurate. Gateways set an ETag header and for some types of content they also set Cache-Control:public, max-age=29030400, immutable
. When loading an ipfs site twice, I get etag-304 and local cache hits.
I also prefer having nginx between the public internet and any service as it allows me to quickly control access if I should need to.
Sure, I was just wondering how big the difference is between nginx cache vs no-nginx-cache for items that are pinned or locally cached by the ipfs daemon behind it. If the difference is large, it would mean ipfs might be slow retrieving content from its own datastore in comparison to an static disk cache (it will probably be slower, but how much?). Otherwise, having a proxy caching layer may not be necessary or cost-effective.
You say that nginx caching fixes the slowness of the official gateway, but the comparison is a bit unfair, since you are testing a very busy load-balanced node with lots of content with your own clean box.
The HTTP2 site is caching, so the second page reload takes just 134 milliseconds whereas the IPFS site still takes 2 seconds.
The 2 seconds of difference (which is a lot and surprises me too) may be a result of available bandwitdth, disk speed, ipns name resolution (which I think would happen locally and very fast for your own node), or other parts of the nginx configuration (gzip). I wonder if you are comparing a fresh non-cached retrieval from public gateway vs. a locally cached one response from mem-cache.
In any case, other than proxy caching there are many differences between your node and the public gateway that should be taken into account when making speed comparisons between the two.
By the way, official gateways also have Nginx doing reverse proxying in front of the ipfs gateway. So it’s not a test of “IPFS vs HTTP2” (in fact that comparison is very weird), but rather nginxA+ipfs vs nginxB+ipfs.
That all said, thanks for the tutorial. It’s very illustrative on how to setup a box with an ipfs an strengthen the network.