How to deal with web libraries? (CDN)

Currently on Maidsafe, I dealt with this issue on Alpha 2 by having every website have it’s own assets folder.
Currently on ClearNET, the popularity of using CDN’s is that it has become standard.

My biggest issue with is that I like to test my sites on atom-live-server, without having to constantly readjust my links to fit with the correct network.

1 Like

De-duplication should mean the network acts like a CDN for common content, i.e. it will cache the data at the network level when many people use it.

At the browser level, I suspect there will URL caches enabled at some point too. Currently, there is no caching in the browser (as far as I can see) so this isn’t an issue yet. I’m not sure whether there will/can be persistent URLs for this sort of purpose, but it would be very handy to commit data to the network with a permanent link for this sort of thing.

3 Likes

I was thinking aboit this, too. When developing for the Safe browser, I find myself in need for some libraries, scripts, fonts… etc. So far I simply upload everything to each website, but I thought it would be nice if we create a common ressource for app developpers to pick in when needed, ideally with a browsable ui.
I see some maintenance work needing to be done here, though.
In fact we really want a SafeHub , or GitSafe !

1 Like

It would be great to have DNS names that stick too or can we just use some sort of hash to resolve the file natively? We could then banish the dreaded 404 forever on these resources!

1 Like

without having to constantly readjust my links

you could use constants to declare your links, one batch for atom, one for safe, and either comment/uncomment , or use an if statement to switch from the atom links and the safe ones back and forth ? maybe the code could even detect if it lives on safe or in atom , and switch the constants by itself .

A built-in dependency manager (like npm) would be nice too. You would specify your deps and semvers. That way you would get all bug fixes without rebuilding your app (similar to dynamically linked libraries on Linux).

To achieve this and prevent mutation we can’t use a DNS that we don’t personally control because it is mutable, so we must use direct links to immutable data.

This is feasible, but not yet available because the browser only supports DNS based links at present.

I’m not sure, but I don’t think this can be achieved for embedded links until the SAFE browser itself supports it. I can’t immediately think of a way anyway!

2 Likes

@joshuef, is this something being considered? Surely there is value in both having mutable and immutable URLs, depending on the context. If we want to link the latest version, the mutable URL would be best. If we want to link to a specific version, then an immutable URL would be great.

2 Likes

It’s been under consideration for a while (I wrote an RFC about it ages ago) and I’m sure it will happen eventually, but think there are other priorities still.

3 Likes

right now you can store ,say an image, in b64 in an immutable. Then when the site needs it, you fetch the b64 and stuff it into a new Image () and put your image in a getElementbyID, for instance.
Not sure if we can do something similar for a js file to be used an as include, though, but I have a feeling it can be done.

EDIT : This should do the trick :

Care to make a PoC demo?

sure I will try tomorrow, as now I am out in the wild :slight_smile:

2 Likes

I made a quick demo of how it can work , see: Immutable CDN trick - General - Safe Dev Forum

@moderators, should I send this discussion to safedev, or can it stay here ?

3 Likes

Its fine here for the time being.

1 Like